I’m trying to join a room but I don’t know how to find it
I used I create the JoinARoom function and when I click the Join button, the room does not connect as the name mainServerText.text
using Photon.Pun;
using Photon.Realtime;
using System.Collections;
using System.Collections.Generic;
using TMPro;
using UnityEngine;
public class Connect : MonoBehaviourPunCallbacks
{
[SerializeField] private GameObject connectingPanel;
[SerializeField] private GameObject createRoomPanel;
[SerializeField] private GameObject startGamePanel;
[SerializeField] private GameObject adversaryPanel;
[SerializeField] private TextMeshProUGUI mainServerText;
[SerializeField] private TextMeshProUGUI mainUserText;
[SerializeField] private TextMeshProUGUI otherServerText;
[SerializeField] private TextMeshProUGUI otherUserText;
[SerializeField] private TextMeshProUGUI infoServerText;
private bool isConnected = false;
private const string gameVersion = "0.1";
private const int maxPlayersPerRoom = 2;
[SerializeField] int correntNumber = 0;
[SerializeField] int playerCount = 0;
public void Update()
{
playerCount = PhotonNetwork.CurrentRoom.PlayerCount;
}
public void CreateServer()
{
createRoomPanel.SetActive(false);
connectingPanel.SetActive(true);
isConnected = true;
PhotonNetwork.ConnectUsingSettings(gameVersion);
}
public override void OnConnectedToMaster()
{
if(playerCount == 0)
{
CreateARoom();
}
}
public void CreateARoom()
{
RoomOptions roomOptions = new RoomOptions();
roomOptions.IsVisible = true;
roomOptions.MaxPlayers = 2;
PhotonNetwork.CreateRoom(mainServerText.text, roomOptions, TypedLobby.Default);
Debug.Log("You create room: " + mainServerText.text);
correntNumber = 1;
}
public void JoinARoom()
{
PhotonNetwork.JoinRoom(mainServerText.text);
Debug.Log("You join in the room: " + mainServerText.text);
correntNumber = 2;
}
public override void OnJoinedRoom()
{
Debug.Log(playerCount.ToString());
if (playerCount != maxPlayersPerRoom)
{
infoServerText.text = "Waiting for the opponent...";
}
else
{
infoServerText.text = "You are connected!";
if (correntNumber == 1)
{
connectingPanel.SetActive(false);
startGamePanel.SetActive(true);
}
else if (correntNumber == 2)
{
connectingPanel.SetActive(false);
adversaryPanel.SetActive(true);
}
}
}
}