Forum Discussion
Monosphere
4 years agoExplorer
How do i access oculus username?
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...
julienkay
4 years agoAdventurer
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;
}
}
}
Monosphere
4 years agoExplorer
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
Quick Links
- Horizon Developer Support
- Quest User Forums
- Troubleshooting Forum for problems with a game or app
- Quest Support for problems with your device
Other Meta Support
Related Content
- 10 months ago
- 1 year ago
- 2 months ago
- 4 months ago