[英]Create Room No overloaded Method Error
當我嘗試使用PhotonNetwork.CreateRoom()
函數時出現錯誤。 我正在嘗試傳遞6個參數。
我的Unity版本是4.7.2 ,此功能來自光子雲插件。
CheckPlayerNameAndRoom();
PhotonNetwork.player.name = playerName;
Hashtable setMapName = new Hashtable();
setMapName["MapName"] = allMaps[selectedMap].mapName;
setMapName["RoundDuration"] = roundDuration;
setMapName["GameMode"] = gameMode;
string[] exposedProps = new string[3];
exposedProps[0] = "MapName";
exposedProps[1] = "RoundDuration";
exposedProps[2] = "GameMode";
//Create new Room
PhotonNetwork.CreateRoom(newRoomName, true, true, maxPlayers, setMapName, exposedProps);
這僅表示您將錯誤的參數傳遞給CreateRoom函數。
根據光子文檔 , CreateRoom
函數有3個重載。
static bool CreateRoom (string roomName)
static bool CreateRoom (string roomName, RoomOptions roomOptions, TypedLobby typedLobby)
static bool CreateRoom (string roomName, RoomOptions roomOptions, TypedLobby typedLobby, string[] expectedUsers)
這些功能均不采用bool或6個參數。 遇到此類問題時,請始終檢查文檔。
下面是有關如何使用每種方法重載的示例。
string newRoomName = "AloneWolf";
if(CreateRoom (newRoomName))
{
//Success
}
要么
string newRoomName = "AloneWolf";
RoomOptions roomOptions = new RoomOptions();
TypedLobby typedLobby = new TypedLobby ();
if(CreateRoom (newRoomName, roomOptions, typedLobby))
{
//Success
}
要么
string newRoomName = "AloneWolf";
RoomOptions roomOptions = new RoomOptions();
TypedLobby typedLobby = new TypedLobby ();
string[] expectedUsers = { "AloneWolf","OtherUsers"};
if(CreateRoom (newRoomName, roomOptions, typedLobby, expectedUsers))
{
//Success
}
謝謝你的回答,我寫這段代碼
Hashtable roomProps = new Hashtable() { { "MapName", allMaps[selectedMap].mapName }, { "RoundDuration", roundDuration },{ "GameMode", gameMode } }; string[] roomPropsInLobby = { "MapName", "RoundDuration" ,"GameMode" }; RoomOptions roomOptions = new RoomOptions(); roomOptions.customRoomProperties = roomProps; roomOptions.customRoomPropertiesForLobby = roomPropsInLobby; roomOptions.isVisible = true; roomOptions.maxPlayers = (byte)maxPlayers; PhotonNetwork.CreateRoom(newRoomName,roomOptions,TypedLobby.Default);
它可以使人們加入游戲並看到房間中的最多玩家。 再次感謝您好運。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.