using UnityEngine;
namespace com.example.namespace
{
public class Launcher : Photon.PunBehaviour
{
#region Public Variables
[Tooltip("The maximum number of players per room. When a room is full, it can't be joined by new players, and so a new room will be created.")]
public byte MaxPlayersPerRoom = 4;
#endregion
#region Private Variables
string _gameVersion = "1";
#endregion
#region MonoBehaviour CallBacks
public PhotonLogLevel Loglevel = PhotonLogLevel.Informational;
void Awake()
{
PhotonNetwork.autoJoinLobby = false;
PhotonNetwork.automaticallySyncScene = true;
PhotonNetwork.logLevel = Loglevel;
}
#endregion
#region Public Methods
public void Connect()
{
{.
PhotonNetwork.JoinRandomRoom();
progressLabel.SetActive(true);
controlPanel.SetActive(false);
}
else{
// #Critical, we must first and foremost connect to Photon Online Server.
PhotonNetwork.ConnectUsingSettings(_gameVersion);
progressLabel.SetActive(false);
controlPanel.SetActive(true);
}
}
[Tooltip("The UI Panel to let the user enter name, connect and play")]
public GameObject controlPanel;
[Tooltip("The UI Label to inform the user that the connection is in progress")]
public GameObject progressLabel;
#endregion
#region Photon.PunBehaviour CallBacks
public override void OnConnectedToMaster()
{
Debug.Log("DemoAnimator/Launcher: OnConnectedToMaster() was called by PUN");
PhotonNetwork.JoinRandomRoom();
}
public override void OnPhotonRandomJoinFailed(object[] codeAndMsg)
{
Debug.Log("DemoAnimator/Launcher:OnPhotonRandomJoinFailed() was called by PUN,");
PhotonNetwork.CreateRoom(null, new RoomOptions() { MaxPlayers = 4 }, null);
}
public override void OnJoinedRoom()
{
Debug.Log("DemoAnimator/Launcher: OnJoinedRoom() called by PUN. Now this client is in a room.");
}
public override void OnDisconnectedFromPhoton()
{
progressLabel.SetActive(true);
controlPanel.SetActive(false);
Debug.LogWarning("DemoAnimator/Launcher: OnDisconnectedFromPhoton() was called by PUN");
}
#endregion
}
}
Hi everybody. still new to this forum and to unity. Anywho, I’m on the last part of part 2 on the PUN tutorial found here. I am trying to do the last part where the UI is supposed to show the word “Connecting…” right above my “play” button, but I am having issues getting “Connecting…” to appear when I hit the button. I tried to edit the part where it says:
{
if (PhotonNetwork.connected)
{
OnPhotonRandomToinFailed() and we'll create one.
PhotonNetwork.JoinRandomRoom();
progressLabel.SetActive(true);
controlPanel.SetActive(false);
}
else{
PhotonNetwork.ConnectUsingSettings(_gameVersion);
progressLabel.SetActive(false);
controlPanel.SetActive(true);
}
}
I keep on changing the values for “progressLabel.SetActive(false);” & “controlPanel.SetActive(true);” back and forth to “progressLabel.SetActive(true);” & “controlPanel.SetActive(false);” for all of the true/false values, but its not doing what it should which it should say “Connecting…” as soon as I hit the play button, except “Connecting…” stays on the canvas for the UI and then disappears when I click on the play button. Its even more frustrating when the directions on Part 2 of the tutorial says “2. Add the two following properties within the Public Properties Region” when there is no Public Properties region. (second part of the question) What am I supposed to do here since there is no Public Properties region? Is it Public Methods that I am supposed to be adding to? I’m so lost right now.
Thank you in advance.