C# Unity Photon room.SetCustomProperties不工作
根据我在网上查找的内容,大多数示例都包含一个参数,即单个C# Unity Photon room.SetCustomProperties不工作,c#,unity3d,photon,C#,Unity3d,Photon,根据我在网上查找的内容,大多数示例都包含一个参数,即单个哈希表。然而,我不断得到一个错误,说没有只接受一个参数的重载方法。它需要三个。这就是我提出的例子,但我仍然得到一个错误,说它有无效的参数 如何使用room.SetCustomProperties public void PlacingStone () { Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }}; Has
哈希表。然而,我不断得到一个错误,说没有只接受一个参数的重载方法。它需要三个。这就是我提出的例子,但我仍然得到一个错误,说它有无效的参数
如何使用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=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" );
}
如果这是necro,很抱歉,但是如何更新该值(例如,一个名为“isStreaming”的bool)。
using Hashtable = ExitGames.Client.Photon.Hashtable;
public void SetProperties () {
Hashtable setPlacingStone = new Hashtable {{ RoomProperties.PlacingStone, true }
PhotonNetwork.room.SetCustomProperties ( setPlacingStone );
StartCoroutine ( "WaitOnStone" );
}