Forum Discussion
Shruggger
5 years agoExplorer
(Unity) How to get players OculusID / Username
I have been trying to retrieve the username but I can't get anything to work. Here's the program below. It retrieves the user's OculusID and sets a variable that is synced on the network. When this is run, it returns as a null reference exception.
Users.GetLoggedInUser().OnComplete((Message<User> uMsg) =>
{
if (uMsg.IsError)
{
Debug.LogError("Platform: GetLoggedInUser() failed. Reason: " + uMsg.GetError().Message);
return; // no need to go any further if local user can't be determined
}
else
{
// success, process user structure we receive in uMsg.Data
newClientClass.nickName = uMsg.Data.OculusID;
}
});
I cannot find any example code or documentation on how to properly implement this.
2 Replies
- foxvalleysoccerProtege
any update on this? Get it working?
- pro_zacMeta Employee
The SharedSpaces Unity sample shows how.
lines 223 to 240
Users.GetLoggedInUser().OnComplete(OnLoggedInUser); }); } private void OnLoggedInUser(Message<Oculus.Platform.Models.User> message) { if (message.IsError) { LogError("Cannot get user info", message.GetError()); return; } // Workaround. // At the moment, Platform.Users.GetLoggedInUser() seems to only be returning the user ID. // Display name is blank. // Platform.Users.Get(ulong userID) returns the display name. Users.Get(message.Data.ID).OnComplete(localPlayerState.Init); }
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
- 11 months ago
- 2 years ago