Skip to main content
Participant
September 26, 2017

Getting my Oculus id (Username)

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);
    }

This topic has been closed for replies.

3 replies

Inspiring
September 26, 2017
Did you initialize the platform by calling





Oculus.Platform.Core.Initialize(); 

first? 
rfunk82Author
Participant
September 26, 2017


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)



rfunk82Author
Participant
September 26, 2017
I fixed it by adding  Oculus.Platform.Request.RunCallbacks()