我已经看到类似问题的答案更多,但是这些都没有帮助我。我希望你可以。
我有一个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);
}
}
'MatchDesc'已重命名为'MatchInfoSnapshot'。只需更换它,它应该可以正常工作。