08-21-2018 02:16 AM
08-27-2018 05:11 PM
Texture2D player_avatar;
void Start()
{
if ( XRSettings.loadedDeviceName == "Oculus" )
{
Core.AsyncInitialize();
Entitlements.IsUserEntitledToApplication().OnComplete( EntitlementCallback );
}
}
void EntitlementCallback( Message msg )
{
if ( msg.IsError )
{
Debug.LogError( "You are NOT entitled to use this app." );
UnityEngine.Application.Quit();
}
else
{
Users.GetLoggedInUser().OnComplete( GetLoggedInUserCallback );
Request.RunCallbacks();
}
}
async void GetLoggedInUserCallback( Messagemessage )
{
Avatar = Instantiate( Resources.Load("MyCustomPrefab"));
Avatar.StartWithControllers = true;
Avatar.oculusUserID = message.Data.ID.ToString();
player_avatar = await FetchPlayerImage( message.Data.ImageURL );
}
async TaskFetchPlayerImage( string url )
{
url = url.Trim();
if ( !string.IsNullOrEmpty( url ) )
{
WWW w = new WWW( url );
while ( !w.isDone )
await Task.Delay( 100 );
if ( string.IsNullOrEmpty( w.error ) )
return w.texture;
else
Debug.LogWarning( w.error );
}
return null;
}
08-28-2018 06:29 AM
This worked for me! Thank you so much 🙂
imperativity said:
Hi,
I'll forward this to our platform SDK team and see if they can offer guidance on whether this is exposed behavior or road-mapped for the future.
EDIT:
You can currently retrieve a user's avatar profile picture URI using this:
https://graph.oculus.com/<userID>?access_token=<token>&fields=avatar_v2{avatar_image{uri}}
and by using the below if you are still using older (deprecated) avatars:
avatar{avatar_image{uri}}
05-12-2022 08:07 AM - edited 05-12-2022 08:08 AM
Hi guys, the following url returns a json containing only the user id, and no image url. I'm guessing this method is now outdated...?
Are you aware of any other way to get the avatar image by any chance?