Are custom properties overwritten if I pass a new hashtable without older values?
Options
Hi,
I have a quite simple question, and just as it says in the title, if I pass a new hashtable to my player's custom properties that don't include a property I set before, will it be overwritten and removed?
For example. Every time I open the game I give the player a random value. So I do:
Now, when my player joins a room they will get a few other properties, for example, like if they are ready to play.
Now when I've set a new property and didn't include the old "myValue" in this, is "myValue" gone or is it still there? Will I still be able to access "myValue" later in the game after this? If not, is there a way so I don't have to include every property I set to the player in every line when I need to set some properties?
I would test this myself but my game is in such a mess that I would take so much work to actually test this.
I have a quite simple question, and just as it says in the title, if I pass a new hashtable to my player's custom properties that don't include a property I set before, will it be overwritten and removed?
For example. Every time I open the game I give the player a random value. So I do:
PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { "myValue", 1234 } });
Now, when my player joins a room they will get a few other properties, for example, like if they are ready to play.
PhotonNetwork.player.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() { { "ready", false } });
Now when I've set a new property and didn't include the old "myValue" in this, is "myValue" gone or is it still there? Will I still be able to access "myValue" later in the game after this? If not, is there a way so I don't have to include every property I set to the player in every line when I need to set some properties?
I would test this myself but my game is in such a mess that I would take so much work to actually test this.
0
Comments
-
So I actually took the time to test it now and it seems like it does not overwrite older values. That's awesome!
I've basically answered my own question now. Sorry for not actually doing this test before asking.1 -
Hi,
It's explained in the docAlways use SetCustomProperties to change values. To reduce network traffic, set only values that actually changed. New properties are added, existing values are updated. Other values will not be changed, so only provide values that changed or are new.
so indeed, only set the only values you need to change, for network traffic optimization.
Bye,
Jean
0 -
Thanks for the comments!
I'm honestly a bit mad at myself that I didn't check the docs and didn't test it myself. In the future, I promise to always check the docs and test before I ask!0 -
no worries at all0