Overview
Creates a new room and automatically joins the room as its room owner.
Methods | ​ |
​CreateRoom(bool, int, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified wantRT, and PlayerLimit. |
​CreateRoom(string, bool, int, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified string room custom data, wantRT, and PlayerLimit. |
​CreateRoom(object, bool, int, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified serializable object room custom data, wantRT, and PlayerLimit. |
​CreateRoom(string, bool, int, SWLobbyIndexData, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified string room custom data, wantRT, PlayerLimit, and index data. |
​CreateRoom(object, bool, int, SWLobbyIndexData, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified serializable object room custom data, wantRT, PlayerLimit, and index data. |
​CreateRoom(string, bool, int, int, bool, SWLobbyIndexData, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified string room custom data, wantRT, PlayerLimit, PlayerTimeToLive, isPrivate, and index data. |
​CreateRoom(object, bool, int, int, bool, SWLobbyIndexData, Action<bool, string, SWLobbyError>)​ | Called by players to begin an asynchronous operation to create a room and using the specified serializable object room custom data, wantRT, PlayerLimit, PlayerTimeToLive, isPrivate, and index data. |
Class | ​ |
​SWLobbyIndexData​ | The index data object of a room. |
​SWLobbyError​ | The error that occurred when a lobby API operation failed. |
Maximum size of a room custom data is 5KB.
In this example, we created a room with serializable object as its custom data. The custom room data has two teams and we assigned the local player to team1.
// Serializable classes for room custom data[Serializable]public class RoomCustomData {public string name;public TeamCustomData team1;public TeamCustomData team2;}​[Serializable]public class TeamCustomData {public List < string > players = new List < string > ();}
// Create a new RoomCustomData object;RoomCustomData roomData = new RoomCustomData();​// Set its name to "New Room"roomData.name = "New Room";​// Create two TeamCustomData objects// Assign them to team1 and team2 of the RoomCustomData objectroomData.team1 = new TeamCustomData();roomData.team2 = new TeamCustomData();​// Assign local player to team1 by// adding local player's PlayerId to the players list of team1roomData.team1.players.Add(NetworkClient.Lobby.PlayerId);​// create a new room with the RoomCustomData serializable objectNetworkClient.Lobby.CreateRoom(roomData, true, 4, (successful, roomId, error) =>{if (successful) {Debug.Log("Room created " + roomId);}else {Debug.Log("Failed to create room " + error);}});