Clear all

CombuManager.localUser confusion

Eminent Member Registered

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.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. 😀 

Topic starter Posted : 22/03/2020 11:00 pm
Prominent Member Admin

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);



Posted : 23/03/2020 12:17 am
Eminent Member Registered

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.

Topic starter Posted : 23/03/2020 1:47 am