Unity Photon room.SetCustomProperties 不工作
Unity Photon room.SetCustomProperties Not Working
根据我在网上查到的,大部分例子都是一个参数,就是一个Hashtable
。但是,我一直收到一条错误消息,说没有只接受一个参数的重载方法。它需要三个。这是我想出的例子,但我仍然收到一个错误,说它有无效的参数。
如何使用 room.SetCustomProperties
?
public void PlacingStone ()
{
Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }};
Hashtable currentValues = new Hashtable {{ RoomProperties.PlacingStone,
(bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] }};
PhotonNetwork.room.SetCustomProperties ( setPlacingStone, currentValues, true );
StartCoroutine ( "WaitOnStone" );
}
您的问题是您正在尝试使用多个哈希表。您可以通过以下方式向哈希表添加不同的内容:
PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() {
{ RoomProperties.PlacingStone, true }, { RoomProperties.PlacingStone,
(bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] } });
或
Hashtable t = new Hashtable();
t.Add(RoomProperties.PlacingStone, true);
t.Add(RoomProperties.PlacingStone, (bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] );
PhotonNetwork.room.SetCustomProperties(t);
谢谢!问题是光子哈希表。我需要像你说的那样使用那些,我还添加了 using Hashtable = ExitGames.Client.Photon.Hashtable;位于页面顶部以使其更容易。
using Hashtable = ExitGames.Client.Photon.Hashtable;
public void SetProperties () {
Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }
PhotonNetwork.room.SetCustomProperties ( setPlacingStone );
StartCoroutine ( "WaitOnStone" );
}
根据我在网上查到的,大部分例子都是一个参数,就是一个Hashtable
。但是,我一直收到一条错误消息,说没有只接受一个参数的重载方法。它需要三个。这是我想出的例子,但我仍然收到一个错误,说它有无效的参数。
如何使用 room.SetCustomProperties
?
public void PlacingStone ()
{
Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }};
Hashtable currentValues = new Hashtable {{ RoomProperties.PlacingStone,
(bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] }};
PhotonNetwork.room.SetCustomProperties ( setPlacingStone, currentValues, true );
StartCoroutine ( "WaitOnStone" );
}
您的问题是您正在尝试使用多个哈希表。您可以通过以下方式向哈希表添加不同的内容:
PhotonNetwork.room.SetCustomProperties(new ExitGames.Client.Photon.Hashtable() {
{ RoomProperties.PlacingStone, true }, { RoomProperties.PlacingStone,
(bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] } });
或
Hashtable t = new Hashtable();
t.Add(RoomProperties.PlacingStone, true);
t.Add(RoomProperties.PlacingStone, (bool) PhotonNetwork.room.customProperties [ RoomProperties.PlacingStone ] );
PhotonNetwork.room.SetCustomProperties(t);
谢谢!问题是光子哈希表。我需要像你说的那样使用那些,我还添加了 using Hashtable = ExitGames.Client.Photon.Hashtable;位于页面顶部以使其更容易。
using Hashtable = ExitGames.Client.Photon.Hashtable;
public void SetProperties () {
Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }
PhotonNetwork.room.SetCustomProperties ( setPlacingStone );
StartCoroutine ( "WaitOnStone" );
}