cancel
Showing results for 
Search instead for 
Did you mean: 

How do i access oculus username?

Monosphere
Explorer

I've searched everywhere and i have not been able to find a single post about how to get a string of text which contains the local player's username. Does anyone know how to do it with v33, and if so can you go into detail a bit, thankyou.

5 REPLIES 5

julienkay
Adventurer

Getting the username of a player is part of the Oculus Platform SDK. The documentation on how to use it in Unity can be found here. The most important prerequisite is that you'll need an AppID by creating an application in the Developer Dashboard.

 

To start using the Platform SDK, you'll first have to do an entitlement check as outlined here.

Using either Platform.Core.Initialize(appID) or Platform.Core.AsyncInitialize(appID)

 

Then, you'll be able to use Platform.Users.GetLoggedInUser() to retrieve a username.

 

 

using Oculus.Platform;
using Oculus.Platform.Models;
using UnityEngine;

public class PlatformSDKTest : MonoBehaviour {

  private void GetUserName() {
     Oculus.Platform.Users.GetLoggedInUser().OnComplete(GetLoggedInUserCallback);
  }

  private void GetLoggedInUserCallback(Message msg) {
    if (!msg.IsError) {
      User user = msg.GetUser();
      string userName = user.OculusID;
      string displayName = user.DisplayName;
    }
  }
}

 

 

 

Hello, and thankyou.

This was able to give me the username and display name that i needed but i require some help on getting that name and putting it on something like a UI, i am sideloading the app onto my vr so i dont know if it is a problem with my code or if you arent able to access the user from sideloaded apps


Thankyou

julienkay
Adventurer

Is there any specific error you're getting? I'm not sure which step you're stuck on.

Make sure you've added the AppID in the OculusPlatformSettings file in Unity. To be safe, I'd also upload an initial build to a release channel in the Oculus Developer Dashboard.

This blog post might also be helpful to you.

Sorry this one was my bad, there was an obvious problem that skipped over my head. It all works now and i can successfully get a player's username and id and all those details. Thankyou

Is it native Oculus Id? Can you get somehow Facebook id, considering that most of users have merged accounts or login with Facebook?