10-15-2021 12:27 AM
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.
10-15-2021 03:01 AM - edited 10-15-2021 04:00 AM
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;
}
}
}
10-15-2021 06:54 AM
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
10-15-2021 08:52 AM
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.
10-15-2021 08:57 AM
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
06-24-2022 01:26 PM
Is it native Oculus Id? Can you get somehow Facebook id, considering that most of users have merged accounts or login with Facebook?