我开始使用Photon Networking for Unity,并遇到了问题。我想添加到播放器的CustomProperties中,然后我想调试结果。但是,调试打印“空”。我在创建房间后这样做。Photon Networking Unity AllProperties not setting
有趣的是在OnPhotonPlayerPropertiesChanged()
它打印“改变”,只有当我执行SetPlayerPosition()
时。
但是,如果我然后检查customproperties里面的键是不包含它,所以它不打印“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
}
你是什么意思,“如果我然后检查customproperties内部的密钥是不包含它所以它” - 什么是“它”? –
散列表不包含这些键,并且不包含这些值。 –