- Home /
Help importing personalized Oculus avatar
I'm trying to render personalized avatars in the Editor with a test user. I've got an Oculus Quest using Oculus Link. I'm using Unity 2019.4.25 and the Oculus XR Plugin 1.8.1. I created an app on the Oculus Developer Dashboard (for the Quest). I've created a few test users. I'm targeting PC/Standalone in build settings, even though I plan on switching to Android. I've logged in with one of the test users to my Quest, and I've logged in on the OculusPlatformSettings. I've put the App ID in the OvrAvatarSettings and OculusPlatformSettings (in both Rift App Id and Quest fields). I customized the Avatar for my test user.
I perform and pass my entitlement check successfully, then I successfully get my user ID, then I instantiate an Avatar and apply that ID to the OvrAvatar script. I've also tried applying some of the test IDs from the docs page, but I always see the same, unchanging avatar.
I'm kinda stuck here. Does anyone have any leads?
Here's my code:
using UnityEngine;
using System.Collections;
using MyUtility;
using UnityEngine.Events;
using Oculus;
using Core = Oculus.Platform.Core;
using Entitlements = Oculus.Platform.Entitlements;
public class EntitlementChecker : MonoBehaviour
{
//------------------------------------------------------------------------CONSTANTS:
private const string LOG_TAG = "EntitlementChecker";
public bool VERBOSE = false;
//---------------------------------------------------------------------------FIELDS:
[SerializeField]
private UnityEvent onVerified, onFailed;
//---------------------------------------------------------------------MONO METHODS:
void Awake()
{
try
{
if( ! Core.IsInitialized() )
{
vLog( "Initializing Core" );
Core.AsyncInitialize();
//Core.Initialize();
}
Entitlements.IsUserEntitledToApplication().OnComplete( checkCallback );
}
catch( System.Exception e )
{
LOG_TAG.TPrint( "Failed initializing core or verifying entitlements: " + e );
if( onFailed != null ) onFailed.Invoke();
}
}
//--------------------------------------------------------------------------HELPERS:
void checkCallback( Oculus.Platform.Message message )
{
if( message.IsError )
{
vLog( "Error checking entitlements: " + message.GetError().Message );
if( onFailed != null ) onFailed.Invoke();
return;
}
vLog( "Successfully verified user's entitlements!" );
if( onVerified != null ) onVerified.Invoke();
}
private void vLog( string message )
{
if( VERBOSE ) LOG_TAG.TPrint( message );
}
}
The onVerified Event will set active a GameObject with the following script:
using UnityEngine;
using System.Collections;
using MyUtility;
using Oculus.Platform;
using Oculus.Platform.Models;
using UnityEngine.Events;
public class UserAvatar : MonoBehaviour
{
//------------------------------------------------------------------------CONSTANTS:
private const string LOG_TAG = "PlatformManager";
public bool VERBOSE = false;
//--------------------------------------------------------------------INNER CLASSES:
//---------------------------------------------------------------------------FIELDS:
[SerializeField]
private OvrAvatar avatar;
[SerializeField]
private GameObject avatarPrefab;
public OvrAvatar Avatar { get; private set; }
// Set in getLoggedInUserCallback
public User UserData { get; private set; }
public string UserDataString
{
get
{
if( UserData == null ) return "";
return "DisplayName: " + UserData.DisplayName + ", " +
"ID: " + UserData.ID + ", " +
"OculusID: " + UserData.OculusID + ", " +
"PresenceStatus: " + UserData.PresenceStatus;
}
}
[SerializeField]
private UnityEvent onLoggedIn, onFailedLogin;
//---------------------------------------------------------------------MONO METHODS:
void Awake()
{
try
{
if( ! Core.IsInitialized() )
{
vLog( "Initializing Core" );
Core.AsyncInitialize();
//Core.Initialize();
}
Users.GetLoggedInUser().OnComplete( getLoggedInUserCallback );
Request.RunCallbacks();
}
catch( System.Exception e )
{
LOG_TAG.TPrint( "Failed initializing core or verifying entitlements: " + e );
}
}
//--------------------------------------------------------------------------METHODS:
//--------------------------------------------------------------------------HELPERS:
private void getLoggedInUserCallback( Message<User> message )
{
if( message.IsError )
{
LOG_TAG.TPrint( "Error getting logged in user: " +
message.GetError().Message );
if( onFailedLogin != null ) onFailedLogin.Invoke();
return;
}
Avatar = Instantiate( avatarPrefab ).GetComponent<OvrAvatar>();
UserData = message.Data;
vLog( "Got logged in user:\n " + UserDataString );
Avatar.oculusUserID = "" + UserData.ID;
//Avatar.oculusUserID = "10150022857770130";
Avatar.ShowThirdPerson = true;
if( onLoggedIn != null ) onLoggedIn.Invoke();
}
private void vLog( string message )
{
if( VERBOSE ) LOG_TAG.TPrint( message );
}
}