Unity CrossPlatform Sample Scene

The Unity CrossPlatform sample scene shows how Oculus Avatars can now be used, with some limitations, on non-Oculus PC platforms. The sample scene demonstrates this by querying and showing Avatars without initializing Oculus-only Platform features that are still required for complete Avatar functionality.

Regardless of platform, it’s currently possible to use an Oculus user’s customized Avatar in any app that uses the method shown in the sample scene. However, cross-platform Avatar support is still in its early stages and there are currently some limitations. For example, non-Oculus users can't customize their own Avatars. Instead, there are 12 default Avatars included in the sample scene that can be provided as options to non-Oculus users. Another limitation is that controller bindings for hand poses on non-Oculus controllers haven't been implemented yet.

Setup Instructions

  1. Install Steam and SteamVR. This is a requirement for OpenVR development in Unity.

  2. Create a new Unity project.

  3. Import the Oculus Integration for Unity from the Asset Store.

  4. Open the CrossPlatform scene in Assets/Oculus/Avatar/Samples/CrossPlatform.

  5. From the Oculus Dashboard, create a placeholder Oculus Rift app and copy the App ID.

  6. On the menu bar, select Oculus Avatars > Edit Configuration and paste the App ID into the Oculus Rift App Id text box in the Inspector window.

    • Note: In a multi-platform app that includes Oculus Rift, Oculus Platform features would normally be initialized at this point. This has been omitted from this sample scene to show that Avatars work without Platform features.
  7. Make sure OpenVR is enabled and prioritized for use when the scene is played:

    1. From the menu bar, select Edit > Project Settings > Player.

    2. In the Inspector window, expand XR Settings and add OpenVR if it’s not already there.

    3. Remove Oculus (or drag it below OpenVR) so that OpenVR is used when the scene is played.

  8. Click the Play button.

The scene should play using SteamVR rather than the Oculus platform, and you'll see 12 different Oculus Avatars in front of you.

Using Avatars in Your Cross-Platform Apps

To use Avatars in cross-platform apps, do the following:

  • Make sure you have a network connection.

  • Import the Oculus Integration for Unity.

  • Place your App ID in the Oculus Rift App Id field at Oculus Avatars > Edit Configuration.

  • Use LocalAvatar GameObjects for Avatars.

  • Use Oculus User IDs in the Oculus User ID field of the OVR Avatar (Script) component of the LocalAvatar GameObjects.

The scene contains 12 LocalAvatar GameObjects, each with a different customization. These Oculus User IDs are available to be used by non-Oculus users in your own app.

When you replicate a scene to users in a cross-platform multiplayer app with both Oculus and non-Oculus users, you must include a value for the Oculus User ID field for every user to use their Avatar. For Oculus users, it will be their own Oculus User ID. Currently, for non-Oculus users, it will be one of the 12 Oculus User IDs provided in the sample scene.

Redistribution

When packaging a cross-platform app using Avatars, you must include the following files in a Plugins directory in your Unity project’s Assets folder:

  • libovravatar.dll

  • OvrAvatarAssets.zip

On a PC with the Oculus app installed, these files can be found in C:\Program Files\Oculus\Support\oculus-runtime by default.

Note: Unity’s build process will only copy DLL files in a Plugins directory to the output Plugins directory, so you must manually copy OvrAvatarAssets.zip to the output Plugins directory. You can automate this with a script that adds a custom build command. For more information, see the Unity Build Player Pipeline documentation.

You must also include the Oculus Avatar SDK License with your app.