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

问题描述 投票:0回答:1

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

我有一个Unity2D射击游戏,我尝试为UNET制作菜单。我观看了Brackeys制作的菜单(https://youtu.be/V4oRs26vAw8?list=PLPV2KyIb3jR5PhGqsO7G4PsbEC_Al-kPZ&t=896)上的youtube教程,当他运行项目时,它向我显示错误:“错误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);
    }
}
unity3d server multiplayer
1个回答
0
投票

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

© www.soinside.com 2019 - 2024. All rights reserved.