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

How to submit a issue/bug regarding to SyncEvent?

Discussion in 'Multiplayer' started by Gamrek, Dec 8, 2015.

  1. Gamrek

    Gamrek

    Joined:
    Sep 28, 2010
    Posts:
    164
    Hi,

    Previously I asked a question regarding to SyncEvent which I have a following error when running it: "Cannot cast from source type to destination type." - http://forum.unity3d.com/threads/help-with-syncevent.371552/

    After some testing, I found out if I remove some of the components on the gameobject and add them back again (Network Animator, Network Transform, some other custom scripts), it would work without any issue. It would take me a few attempts as sometimes it would still issue that error after adding back again. I assume this could be a bug in Unity. I cannot say which component causes this issue.

    Does anyone have a similar issue or how can I submit a report to Unity?
    Thanks
     
  2. Chom1czek

    Chom1czek

    Joined:
    Sep 19, 2015
    Posts:
    66
    Thank God, I thought I was the only one with that problem and I would love to use those SyncEvents.
     
  3. Gamba

    Gamba

    Joined:
    Feb 8, 2015
    Posts:
    29
    I just came across this. Glad I'm not the first but it's disappointing that there's been no official response in this time.

    Is there a restriction on the type of object that can be passed through an event? Originally, I wanted to use C#'s EventHandler:

    Code (CSharp):
    1. [SyncEvent]
    2. public event System.EventHandler EventMatchEvent;
    But this gives the following error:
    UNetWeaver error: Exception :System.ArgumentException: Member 'System.EventArgs' is declared in another module and needs to be imported.

    I assume that is something that Unity devs would have to deal with, so I made my own delegate instead:

    Code (CSharp):
    1. public delegate void MatchEventDelegate( object sender, MyEnum enumValue, object data );
    2.  
    3. [SyncEvent]
    4. public event MatchEventDelegate EventMatchEvent;
    But no matter what I passed as data, on the receiving end, the data wasn't able to be cast, causing a cast exception every time.

    I thought maybe it was the type of object being passed so I just passed the value of a NetworkIdentity.netId, just a native uint, but in the end, even that couldn't not be cast from object.

    Finally, I tried by changing the last argument of my delegate to uint and that worked but that's not helpful if I have to create a handful of delegates and events just to cover all the data I might want to pass for an event.

    Ultimately, it seems like there is just a problem with serialization/deserialization across the network when casting to object.

    Is this something that is bug worthy, or is this by design and the documentation is just lacking?