我開始使用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內部的密鑰是不包含它所以它」 - 什麼是「它」? –
散列表不包含這些鍵,並且不包含這些值。 –