Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/unity3d/4.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# Unity Photon room.SetCustomProperties不工作_C#_Unity3d_Photon - Fatal编程技术网

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" );
}