首页 > 解决方案 > 无法连接到一个房间

问题描述

房间设置都是一样的,为什么每次已经创建了房间,玩家却没有连接,而是创建了一个新房间?我收到此警告:操作失败:OperationResponse 225:ReturnCode:32760(未找到匹配项)。参数: {}

public void StartMatchMaking(){
    Debug.LogError(CreateRoomProperties());
    PhotonNetwork.JoinRandomRoom(CreateRoomProperties(), 4);
}

ExitGames.Client.Photon.Hashtable CreateRoomProperties()
{
    return new ExitGames.Client.Photon.Hashtable
    {
        {"bet", bet}
    };
}

private void OnPhotonRandomJoinFailed(object[] codeAndMsg)
{
    CreateRoom();
}

public void CreateRoom(){
    ExitGames.Client.Photon.Hashtable ht = new ExitGames.Client.Photon.Hashtable();
    RoomOptions ro = new RoomOptions();
    ht.Add("bet", bet);
    ro.CustomRoomProperties = ht;
    Debug.LogError(ro.CustomRoomProperties);
    PhotonNetwork.CreateRoom(""+PhotonNetwork.player.NickName, ro, TypedLobby.Default);
}

void OnPhotonPlayerConnected(PhotonPlayer otherPlayer)
{
    Debug.Log("New player: " + otherPlayer.NickName);
}

标签: c#unity3dphoton

解决方案


需要将属性添加到房间设置

customRoomPropertiesForLobby = CreateRoomPropertiesForLobby();
string[] CreateRoomPropertiesForLobby()
{
    return new string[]
    {
        "bet"
    };
}

推荐阅读