Here is my code:
using UnityEngine;
using Photon.Pun;
using TMPro;
using UnityEngine.UI;
using Photon.Realtime;
public class RoomController : MonoBehaviourPunCallbacks
{
public TextMeshProUGUI createRoomField;
public TMP_InputField joinRoomField;
public Button enterGameButton;
public void CreatingRoom()
{
RoomOptions roomOptions = new RoomOptions();
roomOptions.MaxPlayers = 2;
PhotonNetwork.CreateRoom(createRoomField.text, roomOptions, TypedLobby.Default);
}
public override void OnCreatedRoom()
{
Debug.Log("on created rooom successfully ");
}
public override void OnCreateRoomFailed(short returnCode, string message)
{
Debug.Log("not created " + message);
}
public void JoinRoom()
{
PhotonNetwork.JoinRoom(joinRoomField.text);
Debug.Log("Joined room");
}
public override void OnJoinedRoom()
{
enterGameButton.interactable = true;
Debug.Log("Connected to room" + createRoomField.name);
}
}
But I'm facing this issue
CreateRoom failed. Client is on MasterServer (must be Master Server for matchmaking)but not ready for operations (State: PeerCreated). Wait for callback: OnJoinedLobby or OnConnectedToMaster. UnityEngine.Debug:LogError (object) Photon.Pun.PhotonNetwork:CreateRoom (string,Photon.Realtime.RoomOptions,Photon.Realtime.TypedLobby,string[]) (at Assets/Photon/PhotonUnityNetworking/Code/PhotonNetwork.cs:1782) RoomController:CreatingRoom () (at Assets/Scripts/RoomController.cs:19) UnityEngine.EventSystems.EventSystem:Update () (at Library/PackageCache/com.unity.ugui@1.0.0/Runtime/EventSystem/EventSystem.cs:385)
I'm trying to create a room and join to that room when
CreatingRoom()
is called using a button on click in inspector also room name is fetched from a text box ie,(TextMeshProUGUI createRoomField)