O'Reilly logo

Unity Multiplayer Games by Alan Stagner

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Creating rooms

To create a room, there are two methods you can call: CreateRoom, and CreateJoinRoom. The CreateRoom method takes the desired room name (or null if you want a random room name), and room parameters (a dictionary of room properties, such as time limit, map, password, and so on). The CreateJoinRoom method takes both the properties of CreateRoom, and the properties of JoinRoom, as it will either join the room if it exists or create a new one.

One thing to note is that CreateRoom will not automatically establish a connection. It simply returns a string of the room ID on success, and then this is used to connect via JoinRoom.

void OnGUI()
{
  if( roomConnection != null )
    return;

 if( GUILayout.Button( "Create Room", GUILayout.Width( 200f ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required