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:
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. :/

Comments

  • Hertzole
    Hertzole
    edited July 2016
    Options
    So I actually took the time to test it now and it seems like it does not overwrite older values. That's awesome! :smiley:
    I've basically answered my own question now. Sorry for not actually doing this test before asking. :/
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Hertzole,

    Testing things yourself and trial & errors are best approches to learn. It may not be the fastest way that's why documentation is there to help.

    Custom properties are always merged. New keys are added, old values are updated. If value is null, key is removed.
  • jeanfabre
    Options
    Hi,

    It's explained in the doc

    Always 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
  • Hertzole
    Options
    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!
  • jeanfabre
    Options
    no worries at all :)