PUN to PUN 2 upgrade issue

Options
Hi all

We are in the process of upgrading PUN TO PUN 2 in one of our projects.
    void Awake()
    {
        PhotonNetwork.OnEventCall += this.OnEvent;
    }
We are getting an error on this line. How to properly upgrade this to support PUN 2?

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @jgame_ops,

    Thank you for choosing Photon!

    PhotonNetwork.OnEventCall is removed in PUN2.
    You have two options:

    1. use PhotonNetwork.NetworkingClient.EventReceived(EventData) instead.
    2. use IOnEventCallback.OnEvent(EventData). You need to subscribe the event callback though as explained here.

    In PUN2, both options will trigger the callback for all events and not only custom events (custom == event code < 200.
    Also, the signature changed but you can get everything from EventData.

    We will add this to the "Migration Notes".
  • jgame_ops
    Options
    Thank you. Yes, it's not mentioned in the migration notes.