I started using Photon Networking for Unity and I had a problem. I want to add to CustomProperties in the player, and then I want to debug the result. However, the debug prints are "Null." I do this after creating the room.
The funny thing is that in OnPhotonPlayerPropertiesChanged()it it prints “changed” and does this only at runtime SetPlayerPosition().
But if I then verify that the key inside customproperties does not 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);
}
source
share