PUN2 Callbacks / Not being called
Options
GLucas
✭
Long time user, using
i define using
I simply call the below in my connect method:
PUN2
now and had no issue before but seems the callbacks arent being fired now.i define using
Photon.Pun
and Photon.Realtime
in the script as well as deriving from MonoBehaviourPunCallbacks
I simply call the below in my connect method:
PhotonNetwork.GameVersion = "1"; PhotonNetwork.ConnectUsingSettings();And wait for
public override void OnConnectedToMaster()
to be called but it never does. However, when i set the debug log level to all, "Connected to masterserver
" does get posted from the internal PUN debug messages. so im quite confused to why my overrides arent being called. 0
Comments
-
Heres the full script:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; using Photon.Pun; using Photon.Realtime; namespace Project { public class NetworkManager : MonoBehaviourPunCallbacks { #region Public Variables //[Header("Header")] #endregion #region Private Variables #endregion #region Local Variables public static NetworkManager instance; //[Header("Live Debug")] #endregion #region Main Functions void Awake() { //if (instance != null) { // Destroy(this.gameObject); // return; //} instance = this; //DontDestroyOnLoad(this.gameObject); PhotonNetwork.AutomaticallySyncScene = false; } public override void OnEnable() { PlayFabManager.ON_LOGOUT += OnLogout; } public override void OnDisable() { PlayFabManager.ON_LOGOUT -= OnLogout; } void Start() { } void Update() { } #endregion #region Callback Functions void OnLogout(bool value) { Debug.Log(StaticUtilities.StyleText("OnLogout", Color.red, true)); //Disconnect(true); } void Disconnect(bool isLogout) { Debug.Log(StaticUtilities.StyleText("Disconnect", Color.red, true)); //PhotonNetwork.Disconnect(); //UnityEngine.SceneManagement.SceneManager.LoadScene(ApplicationData.loginScene); } public override void OnConnected() { Debug.Log(StaticUtilities.StyleText("OnConnected", Color.blue, true)); } public override void OnConnectedToMaster() { Debug.Log(StaticUtilities.StyleText("OnConnectedToMaster", Color.blue, true)); //PhotonNetwork.LocalPlayer.NickName = PlayFabManager.session.loginResult.InfoResultPayload.PlayerProfile.DisplayName; PhotonNetwork.JoinRandomRoom(); } public override void OnDisconnected(DisconnectCause cause) { Debug.Log(StaticUtilities.StyleText("OnDisconnected", Color.red, true) + " | " + cause.ToString()); } public override void OnJoinedLobby() { Debug.Log(StaticUtilities.StyleText("OnJoinedLobby", Color.blue, true)); PhotonNetwork.JoinRandomRoom(); } public override void OnLeftLobby() { Debug.Log(StaticUtilities.StyleText("OnLeftLobby", Color.blue, true)); } public override void OnCreatedRoom() { Debug.Log(StaticUtilities.StyleText("OnCreatedRoom", Color.blue, true)); } public override void OnCreateRoomFailed(short returnCode, string message) { Debug.Log(StaticUtilities.StyleText("OnCreateRoomFailed", Color.red, true) + " | " + message.ToString()); } public override void OnJoinedRoom() { Debug.Log(StaticUtilities.StyleText("OnJoinedRoom", Color.blue, true)); PhotonNetwork.LoadLevel(ApplicationData.gameplayScene); } public override void OnJoinRoomFailed(short returnCode, string message) { Debug.Log(StaticUtilities.StyleText("OnJoinRoomFailed", Color.red, true) + " | " + message.ToString()); } public override void OnJoinRandomFailed(short returnCode, string message) { Debug.Log(StaticUtilities.StyleText("OnJoinRandomFailed", Color.red, true) + " | " + message.ToString()); CreateRoom(); } public override void OnLeftRoom() { Debug.Log(StaticUtilities.StyleText("OnLeftRoom", Color.blue, true)); } #endregion #region Utility Functions //RoomOptions CustomRoomOptions() { // RoomOptions roomOptions = new RoomOptions { // MaxPlayers = 0, // IsOpen = true, // IsVisible = true, // PublishUserId = true // }; // ExitGames.Client.Photon.Hashtable roomProperties = new ExitGames.Client.Photon.Hashtable { // { "testKey", "testValue" } // }; // roomOptions.CustomRoomProperties = roomProperties; // return roomOptions; //} void CreateRoom() { Debug.Log(StaticUtilities.StyleText("CreateRoom", Color.yellow, true)); PhotonNetwork.JoinOrCreateRoom("Prototype Room", new RoomOptions() { MaxPlayers = 4 }, TypedLobby.Default); } #endregion #region Public Functions public void Connect() { Debug.Log(StaticUtilities.StyleText("Connect", Color.yellow, true)); PhotonNetwork.GameVersion = "1"; PhotonNetwork.ConnectUsingSettings(); //PhotonNetwork.ConnectToBestCloudServer(); //PhotonNetwork.ConnectToRegion("usw"); } #endregion } } #region Base Classes #endregion #region Base Enums #endregion
0 -
I see, there was an additional issue id fixed. I called the base in previous projects and for some reason had an oversight here when overriding. Thanks for pointing it out.0