Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Third Party Problem with photon network

Discussion in 'Multiplayer' started by itisme, Jul 1, 2014.

  1. itisme

    itisme

    Joined:
    Jul 1, 2014
    Posts:
    3
    Hello, maybe you can help.. i am try to understand how photon network works with unity and find some problem with using RaiseEvent.

    i am using

    Code (CSharp):
    1. PhotonNetwork.RaiseEvent(eventcode, datatosend, sendrelaibale, RaiseEventOptions.Default);
    To create my event, and catch it by

    Code (CSharp):
    1. void OnEvent(EventData mevent){...}
    But all i get is error that

    Unhandled Event: 1

    So, what i am doing wrong? Thanks!
     
  2. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,018
    Unlike with the other "callbacks" you need to register your OnEvent delegate method by assigning it to PhotonNetwork.OnEventCall.
    It's different than the other callbacks, because RaiseEvent does not relate to some GameObject and we didn't want to call any instance of that method on all GameObjects that might be instanced over time. Instead, you have to implement a delegate method and register it.

    Your event-handling message must have these parameters: (byte eventCode, object content, int senderId).
    What you got is the OnEvent from Unity (for input, I think).

    Check the remarks in the doc for RaiseEvent. It has an example.
     
  3. itisme

    itisme

    Joined:
    Jul 1, 2014
    Posts:
    3
    First of all thanks for your answer, but can you, please, give more details how i must do it, because i dont really understand what i need to do, i tried, but again not work, and i dont find RaiseEvent in docs. Thanks again
     
  4. tobiass

    tobiass

    Joined:
    Apr 7, 2009
    Posts:
    3,018
    itisme likes this.
  5. itisme

    itisme

    Joined:
    Jul 1, 2014
    Posts:
    3
    Ok! Thank you for answer, now it is clear!