PhotonNetwork.CreateRoom C# (CSharp) Method

CreateRoom() public static method

Creates a room with given name but fails if this room is existing already.
If you don't want to create a unique room-name, pass null or "" as name and the server will assign a roomName (a GUID as string). Call this only on the master server. Internally, the master will respond with a server-address (and roomName, if needed). Both are used internally to switch to the assigned game server and roomName. PhotonNetwork.autoCleanUpPlayerObjects will become this room's AutoCleanUp property and that's used by all clients that join this room.
public static CreateRoom ( string roomName ) : void
roomName string Unique name of the room to create.
return void
    public static void CreateRoom(string roomName)
    {
        Debug.Log("this custom props " + player.customProperties.ToStringFull());
        if (connectionStateDetailed == PeerState.ConnectedToGameserver || connectionStateDetailed == PeerState.Joining || connectionStateDetailed == PeerState.Joined)
        {
            Debug.LogError("CreateRoom aborted: You are already connecting to a room!");
        }
        else if (room != null)
        {
            Debug.LogError("CreateRoom aborted: You are already in a room!");
        }
        else
        {
            if (offlineMode)
            {
                offlineMode_inRoom = true;
                NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnCreatedRoom);
                NetworkingPeer.SendMonoMessage(PhotonNetworkingMessage.OnJoinedRoom);
            }
            else
            {
                networkingPeer.OpCreateGame(roomName, true, true, 0, autoCleanUpPlayerObjects, null, null);
            }
        }
    }

Same methods

PhotonNetwork::CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers ) : void
PhotonNetwork::CreateRoom ( string roomName, bool isVisible, bool isOpen, int maxPlayers, Hashtable customRoomProperties, string propsToListInLobby ) : void

Usage Example

Ejemplo n.º 1
0
    public void btn_crearSalaCustom_click()
    {
        string metodo = "btn_crearSalaCustom_click";

        Debug.Log(metodo + "INICIO");

        string NombreSala      = if_nombreSala.text;
        string NumeroJugadores = dropdown_numeroJugadores.options[dropdown_numeroJugadores.value].text;

        if (string.IsNullOrEmpty(NombreSala))
        {
            NombreSala = "Sala " + Random.Range(1000, 10000);
        }

        RoomOptions OpcioneDeSala = new RoomOptions();

        OpcioneDeSala.MaxPlayers = (byte)int.Parse(NumeroJugadores);

        Debug.Log(OpcioneDeSala.MaxPlayers);

        PhotonNetwork.CreateRoom(NombreSala, OpcioneDeSala);//Requerido importar P.RealTime para confirgurar las opciones     -  Aqui se puede añadir expectador
        Debug.Log(metodo + "FIN");
    }
All Usage Examples Of PhotonNetwork::CreateRoom