In my Unity3D project I am using following code to get user's name:
Code: Select all
UserVariable v = user.GetVariable("nickname");
if(!v.IsNull())
{
nick.text = v.GetStringValue();
}
else
{
Debug.LogError("Can't get nickname.");
}
It works in most of times but randomly get null exception on line if(!v.IsNull())
Firstly I am confused by the fact that it gets correct user variable in most times but there is a few chance to get null? Is it possibly due to internet delay?
Secondly, according to documents v.IsNull() is the right way to indicate that whether a user variable is null or not, but it causes null exception in Unity3D. Should I use v == null to do exception check?
Thanks.