Displaying number of people in matchmake using Unity UI
Hello all. I've just started learning about using multiplayer in unity, I thought PUN is a great place to start. So far I can connect, disconnect, create a room, instantiating players and when the matchmaking is full, then the game starts.
I've got this for my manager so far
What I want is in the matchmaking panel. It displays the amount of people in the room? How could I do this. I already made the variable for the text!! Thanks in advance
I've got this for my manager so far
using System.Collections; using System.Collections.Generic; using UnityEngine; using Photon.Pun; using Photon.Realtime; using UnityEngine.UI; public class MenuManager : MonoBehaviourPunCallbacks { bool isConnecting; [SerializeField] public Button PlayButton_; [Header("Panel's...")] public GameObject LobbyPanel; public GameObject MatchmakePanel; [Header("Text...")] public Text PlayerAmount; private void Awake() { PhotonNetwork.AutomaticallySyncScene = true; } public void PlayButton() { isConnecting = true; PlayButton_.interactable = false; LobbyPanel.SetActive(false); MatchmakePanel.SetActive(true); if (PhotonNetwork.IsConnected) { PhotonNetwork.JoinRandomRoom(); } else { PhotonNetwork.GameVersion = "1"; PhotonNetwork.ConnectUsingSettings(); } } public override void OnConnectedToMaster() { base.OnConnectedToMaster(); if (isConnecting) { PhotonNetwork.JoinRandomRoom(); } } public override void OnJoinRandomFailed(short returnCode, string message) { base.OnJoinRandomFailed(returnCode, message); PhotonNetwork.CreateRoom(null, new RoomOptions { MaxPlayers = 2 }); } public override void OnDisconnected(DisconnectCause cause) { base.OnDisconnected(cause); isConnecting = false; PlayButton_.interactable = true; } public override void OnJoinedRoom() { base.OnJoinedRoom(); } public override void OnPlayerEnteredRoom(Photon.Realtime.Player newPlayer) { base.OnPlayerEnteredRoom(newPlayer); if(PhotonNetwork.PlayerList.Length == 2) { PhotonNetwork.LoadLevel(1); } } public override void OnPlayerLeftRoom(Photon.Realtime.Player otherPlayer) { base.OnPlayerLeftRoom(otherPlayer); } }
What I want is in the matchmaking panel. It displays the amount of people in the room? How could I do this. I already made the variable for the text!! Thanks in advance
0