Reset player custom properties
The whole answer can be found below.
Try Our
Documentation
Please check if you can find an answer in our extensive documentation on PUN.
Join Us
on Discord
Meet and talk to our staff and the entire Photon-Community via Discord.
Read More on
Stack Overflow
Find more information on Stack Overflow (for Circle members only).
Reset player custom properties
madfatcat
2015-01-31 00:33:55
Hi,
I noticed that PhotonNetwork.player keeps customProperties even after disconnecting from Photon. I tried to reset properties by calling PhotonNetwork.player.SetCustomProperties(null) and PhotonNetwork.player.SetCustomProperties(new Hashtable()) , but it doesn't work, custom properties are still contain old Hashtable with data.
To be more specific, here's the complete test code piece:
PhotonNetwork.player.SetCustomProperties(null);
Hashtable ht = PhotonNetwork.player.customProperties;
if (ht != null)
Debug.Log(ht.Count);
Log shows me 2 in the console. How can I nullify custom properties?
Comments
Hi,
The only way to clear player's properties is to set each existing property to null in SetCustomProperties hashtable parameter.
Good point. At the moment, you can't wipe your custom properties but it's a easy fix. In PUN, you still have a local player, even when you're not in a room: PhotonNetwork.player. As you know what you do, you can simply modify the C# code for PhotonPlayer.customProperties. Make the setter public and use it to replace the Hashtable when needed. Alternatively add a method PhotonPlayer.WipeProps() and set the Hashtable then.
Back to top