"OnPlayerNumberingChanged" event never fired ...

Options
Hi,

I am trynig just to fire the OnPlayerNumberingChanged event using the very basic tutorial but the event is never fired ...

Any ideas ?
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using Photon.Pun.UtilityScripts;

public class TestConnect : MonoBehaviourPunCallbacks
{

    string gameVersion = "1";

    public override void OnEnable()
    {
        base.OnEnable();
        PlayerNumbering.OnPlayerNumberingChanged += OnPlayerNumberingChanged;
    }

    void Awake()
    {
        PhotonNetwork.AutomaticallySyncScene = true;
    }

    void Start()
    {
        Connect();
    }

    public override void OnConnectedToMaster()
    {
        Debug.Log("PUN Basics Tutorial/Launcher: OnConnectedToMaster() was called by PUN");
        PhotonNetwork.JoinRandomRoom();
    }

    public override void OnDisconnected(DisconnectCause cause)
    {
        Debug.LogWarningFormat("PUN Basics Tutorial/Launcher: OnDisconnected() was called by PUN with reason {0}", cause);
    }

    public override void OnJoinRandomFailed(short returnCode, string message)
    {
        Debug.Log("PUN Basics Tutorial/Launcher:OnJoinRandomFailed() was called by PUN. No random room available, so we create one.\nCalling: PhotonNetwork.CreateRoom");

        PhotonNetwork.CreateRoom(null, new RoomOptions());
    }

    public override void OnJoinedRoom()
    {
        Debug.Log("PUN Basics Tutorial/Launcher: OnJoinedRoom() called by PUN. Now this client is in a room.");
    }

    public override void OnDisable()
    {
        base.OnDisable();
        PlayerNumbering.OnPlayerNumberingChanged -= OnPlayerNumberingChanged;
    }

    private void OnPlayerNumberingChanged()
    {
        Debug.Log("ON Player Numbering changed");
    }

    public void Connect()
    {
         if (PhotonNetwork.IsConnected)
        {
            PhotonNetwork.JoinRandomRoom();
        }
        else
        {
            PhotonNetwork.GameVersion = gameVersion;
            PhotonNetwork.ConnectUsingSettings();
        }
    }
}
Console Output:
  1. PUN Basics Tutorial/Launcher: OnConnectedToMaster() was called by PUN
  2. PUN Basics Tutorial/Launcher:OnJoinRandomFailed() was called by PUN. No random room available, so we create one.
  3. PUN Basics Tutorial/Launcher: OnJoinedRoom() called by PUN. Now this client is in a room.

And that's it :(

Thanks in advance for your help

Comments

  • Zakhounet
    Options
    I am using Unity 2018.3.12f1 and PUN 2.12
  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Zakhounet,

    Thank you for choosing Photon!

    Did you add PlayerNumbering component/script to the scene?
    This is required.
  • Zakhounet
    Options
    Hi,

    Thanks for your reply. Yes I only have one script (the one above) attached to the only object in the scene.


  • Zakhounet
    Zakhounet
    edited June 2019
    Options
    Thank you, I just realize that indeed the PlayerNumbering component/script was not attached ...

    Problem solved
  • skalapos
    Options
    hi,

    I have an issue with using the PlayerNumbering script. I have attached it normally, but when I call the function p.getPlayerNumber(), I get indexes of first player to be 0 and second player to be -1.
    Although in the gameobject it seems to show correct numbering "1,2"