cancel
Showing results for 
Search instead for 
Did you mean: 

Loading Personalized Avatars script error

kum.penghan
Level 2

I am following the documentation of the Avatar Developer Guide at https://developer.oculus.com/documentation/unity/as-avatars-gsg-unity/ 

 

Under loading personalized avatar, we are supposed to save a script call 'filename.cs'.

however the script text gave a bunch of errors starting with the public class that does not match.

using UnityEngine;
using Oculus.Avatar;
using Oculus.Platform;
using Oculus.Platform.Models;
using System.Collections;

public class <classname> : MonoBehaviour {

    public OvrAvatar myAvatar;

    void Awake () {
        Oculus.Platform.Core.Initialize();
        Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
        Oculus.Platform.Request.RunCallbacks();  //avoids race condition with OvrAvatar.cs Start().
    }

    private void GetLoggedInUserCallback(Message<User> message) {
        if (!message.IsError) {            myAvatar.oculusUserID = message.Data.ID.ToString();
        }
    }
}

Anyone has a solution to this? I have the latest Oculus Integration 32.0 Installed. Using unity 2021.1.

1 REPLY 1

julienkay
Level 6

The documentation you've linked seems to contain malformed HTML tags.

You need to give the file name and the class an appropriate name. E.g. name the file PlatformSDKHelper.cs.

 

Then the code should be:

 

using UnityEngine;
using Oculus.Avatar;
using Oculus.Platform;
using Oculus.Platform.Models;
using System.Collections;

public class PlatformSDKHelper : MonoBehaviour {

    public OvrAvatar myAvatar;

    void Awake () {
        Oculus.Platform.Core.Initialize();
        Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
        Oculus.Platform.Request.RunCallbacks();  //avoids race condition with OvrAvatar.cs Start().
    }

    private void GetLoggedInUserCallback(Message<User> message) {
        if (!message.IsError) {
            myAvatar.oculusUserID = message.Data.ID.ToString();
        }
    }
}