I started using Photon Networking for Unity and I ran into a problem. I want to add to the CustomProperties in the player and then I want to debug the result. However the debug prints "Null". I do this after the room is created.
The funny thing is in the OnPhotonPlayerPropertiesChanged()
it does print "changed" and only does that when I execute SetPlayerPosition()
.
But if I then check for the key inside the customproperties is doesn't contain it so it does not print "10"?
void Awake()
{
SetPlayerPosition();
}
public override void OnPhotonPlayerPropertiesChanged(object[] playerAndUpdatedProps)
{
Debug.Log("changed");
if (PhotonNetwork.player.CustomProperties.ContainsKey("1"))
{
Debug.Log("it works");
}
}
void SetPlayerPosition()
{
ExitGames.Client.Photon.Hashtable xyzPos = new ExitGames.Client.Photon.Hashtable();
xyzPos.Add(1, "10");
xyzPos.Add(2, "5");
xyzPos.Add(3, "10");
PhotonNetwork.player.SetCustomProperties(xyzPos);
// PhotonNetwork.player.SetCustomProperties(xyzPos, null, true); doesnt work either
}
Actually the awnser is that the keys need to be strings!