CombuManager.localU...
 
Notifications
Clear all

CombuManager.localUser confusion

3 Posts
2 Users
0 Reactions
810 Views
(@punchey)
Posts: 36
Trusted Member
Topic starter
 

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

 
Posted : 22/03/2020 11:00 pm
(@skaredcreations)
Posts: 805
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);
});

 

FRANCESCO CROCETTI @ SKARED CREATIONS

 
Posted : 23/03/2020 12:17 am
(@punchey)
Posts: 36
Trusted Member
Topic starter
 

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.

 
Posted : 23/03/2020 1:47 am
Share: