Forum Discussion

🚨 This forum is archived and read-only. To submit a forum post, please visit our new Developer Forum. 🚨
feiyangwang980616's avatar
feiyangwang980616
Honored Guest
5 years ago

I try to get the user ID to set the oculus avatar. However the ID I get is always 0.

How to get the correct user ID

  void Awake()
    {
        Debug.Log("---------------------------------");
        text.text = "begin";
        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();
            text.text = "no error id is: "+ myAvatar.oculusUserID;
            Debug.Log("ID:");
            Debug.Log("message.Data.ID.ToString()");

        }

3 Replies