c# - Unity Photon room.SetCustomProperties 不起作用

标签 c# unity-game-engine photon

根据我在网上查找的内容,大多数示例都采用一个参数,即单个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);

关于c# - Unity Photon room.SetCustomProperties 不起作用,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37368919/

相关文章:

unity-game-engine - Unity3D : How to make a glowing gradient sphere?

objective-c - UIApplicationDelegate 未在 Unity3d 生成的 Xcode AppDelegate 文件中调用

c# - 尝试使用 PunRPC(Unity 和 Photon)发送 RPC 但出现错误 "Object reference not set to an instance of an object"

unity3d - Photon Unity Networking 或 Bolt 或...?

c# - 从程序集中获取所需的运行时版本

javascript - 文本框在 javascript 中接受 1900 - 2050 的日期

c# - 使由数据适配器填充的数据表中的列宽更宽

c# - 从 C# 代码后面传递函数参数

unity-game-engine - 如何使用 gradle 从 aar 中删除库?

c++ - 在 Photon Cloud 上使用 Hashtable 发送数据