cancel
Showing results for 
Search instead for 
Did you mean: 

Getting my Oculus id (Username)

rfunk82
Explorer
I'm trying to get my Oculus username (Unity, c#) so I can use it on my game, but unfortunately I'm getting an error message and I can't find a solution myself. My oculus works in the game,

The error message I get is:


NullReferenceException: Object reference not set to an instance of an object


I'm pretty sure I'm missing a step but I can't find it in the manuals.

This is what I did so far:

I imported using Oculus.Platform;

and then I tried:

I call:

Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);



Method in my class:

    void GetLoggedInUserCallback(Message<User> msg)
    {
        if (msg.IsError)
        {
            Debug.Log("ERROR: " + msg);
            return;
        }



        Debug.Log(" I am " + msg.Data.OculusID);
    }

3 REPLIES 3

delphinius81
Rising Star
Did you initialize the platform by calling





Oculus.Platform.Core.Initialize(); 

first? 

rfunk82
Explorer


Did you initialize the platform by calling





Oculus.Platform.Core.Initialize(); 

first? 


Thanks! I knew I was missing something. Now I get a new error message from the debug error message I wrote (if (msg.IsError) ):


ERROR: Oculus.Platform.MessageWithUser
UnityEngine.Debug:Log(Object)
Target:GetLoggedInUserCallback(Message`1) (at Assets/Scripts/Target.cs:76)
Oculus.Platform.RequestCallback`1:HandleMessage(Message) (at Assets/OculusPlatform/Scripts/Callback.cs:131)
Oculus.Platform.Callback:HandleMessage(Message) (at Assets/OculusPlatform/Scripts/Callback.cs:148)
Oculus.Platform.Callback:RunCallbacks() (at Assets/OculusPlatform/Scripts/Callback.cs:55)
Oculus.Platform.Request:RunCallbacks(UInt32) (at Assets/OculusPlatform/Scripts/Request.cs:35)
Oculus.Platform.CallbackRunner:Update() (at Assets/OculusPlatform/Scripts/CallbackRunner.cs:28)



rfunk82
Explorer
I fixed it by adding  Oculus.Platform.Request.RunCallbacks()