I'm encountering very confusing behavior that I cannot figure out:
If I call CombuManager.localUser.LoadFriends(), then CombuManager.localUser will contain the loaded friend list.
However, if I do:
var localUser = CombuManager.localUser;
localUser.LoadFriends(...);
localUser.friends will have the loaded friends in it, but CombuManager.localUser does not. From everything I can see in the code, CombuManager.localUser returns a reference to a User object. So I am confused why assigning it to a variable and doing something to it wouldn't also affect the original reference, since they both should be pointing to the same object. I don't see any code that creates a copy of the User object, only that returns a reference to it.
For now, I will be careful never to save a reference to CombuManager.localUser and only use CombuManager to access it directly. But if you have any idea why this would be happening, it would solve a mystery for me. 😀Â
It's pretty strange and I'm not able to reproduce this issue, I tried the following code and it works as intended, that is it returns the same result for both (as it should be because as you noticed it's only a reference to the same object and not a new one):
var localUser = CombuManager.localUser;
localUser.LoadFriends((bool success) =>
{
Debug.Log(localUser.friends.Length + " -- " + CombuManager.localUser.friends.Length);
});
Â
FRANCESCO CROCETTI @ SKARED CREATIONS
Yeah, it's really strange and surprising. I've switched to only using CombuManager.localUser for now. But if I switch back and find a reliable way to reproduce the issue, I'll let you know.