Can't trigger OnEvent()

Options
Hi guys,
First time working with PUN.

Soo, I'm stuck on an event call.
I really don't know why and I'm using most of the code from this tutorial on the Photon Site:
https://doc.photonengine.com/en-us/pun/current/tutorials/oculusavatarsdk


public void OnJoinedRoom()
{
Debug.Log("OnJoinedRoom succesful");
int viewId = PhotonNetwork.AllocateViewID();

PhotonNetwork.RaiseEvent(InstantiateVrAvatarEventCode, viewId, true, new RaiseEventOptions() { CachingOption = EventCaching.AddToRoomCache, Receivers = ReceiverGroup.All });
}

private void OnEvent(byte eventcode, object content, int senderid)
{
Debug.Log ("Eureka..");
if (eventcode == InstantiateVrAvatarEventCode)
{
[...]


I'm getting the first Log but It never outputs the second one.

I hope you can help me and feel free to ask if something's unclear :)

Cheers,
Jawah

Comments

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    Hi @Jawah,

    Thank you for choosing Photon!

    What is the value of InstantiateVrAvatarEventCode?
    Custom event codes should be between 0 and 200.
  • Jawah
    Jawah
    edited September 2017
    Options
    @JohnTube
    JohnTube said:

    What is the value of InstantiateVrAvatarEventCode?

    Ah sorry, I forgot to copy it. It's 123 as it is in the tutorial.

  • JohnTube
    JohnTube ✭✭✭✭✭
    Options
    You need to subscribe for the event handler callback:
    private void OnEnable()
        {
            PhotonNetwork.OnEventCall += OnEvent;
        }
    
        private void OnDisable()
        {
            PhotonNetwork.OnEventCall -= OnEvent;
        }
  • Jawah
    Options
    Thank you so much @JohnTube ! Worked like a charm :)
  • Why is the subscription event handler callback not in the getting started guide? It took me a while to figure out why it wasn't working as well which could have been avoided.