由于其保护级别,无法使用Unity OnMatchList

时间:2019-04-22 11:15:13

标签: unity3d server multiplayer

我已经看到类似问题的答案更多,但是没有一个对我有帮助。我希望你可以。

我有一个Unity2D射击游戏,我尝试为UNET制作菜单。我观看了Brackeys提供的youtube教程来制作菜单(https://youtu.be/V4oRs26vAw8?list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ&t=896),当他运行该项目时,它向我显示错误:“错误CS0122:'UnityEngine.Networking.Match.ListMatchResponse'由于其保护级别而无法访问我发现,当您从另一个函数访问一个私有变量时可能会发生这种情况,但是我从Unity访问一个函数,我无法修改其类型(我相信)。有什么想法吗?谢谢

public void OnMatchList(bool success, string extendedInfo, ListMatchResponse matchList)
{
    status.text = "";
    if (matchList == null)
    {
        status.text = "Couldn't get room list.";
        return;
    }

    ClearRoomList();
    foreach(MatchDesc match in matchList.matches)
    {
        GameObject _roomListItemGO = Instantiate(roomListItemPrefab);
        _roomListItemGO.transform.SetParent(roomListParent);
        // Have a component sit on the gameobject
        // that will take care of setting up the name / amount of users.
        // as well as setting up a callback function that will join the game.

        roomList.Add(_roomListItemGO);
    }
}

1 个答案:

答案 0 :(得分:0)

“ MatchDesc”已重命名为“ MatchInfoSnapshot”。 只需更换它,它应该可以正常工作。