I am trying to get the userId, ImageURL, OculusID, and DisplayName for the local Oculus user in my Unity 3D game. I get correctly the userId, the ImageURL, and the OculusID, but the DisplayName is always an empty string.
Here is my code:
Users.GetLoggedInUser().OnComplete(message =>
{
if (!message.IsError)
{
Oculus.Platform.Models.User user = message.GetUser();
userId = user.ID;
ImageURL = user.ImageURL;
OculusID = user.OculusID;
//Empty String
Name = user.DisplayName;
}
else
{
var e = message.GetError();
OvrAvatarLog.LogError($"Error loading user: {e.Message}.", "");
}
});
How to get the DisplayName of the local Oculus User?
It looks like you have to make another request to get the Display Name after you have the user id:
Users.Get(userId).OnComplete(message =>
{
if (!message.IsError)
{
Oculus.Platform.Models.User user = message.GetUser();
Name = user.DisplayName;
}
else
{
var e = message.GetError();
OvrAvatarLog.LogError($"Error loading display name: {e.Message}.", "");
}
});