- Home /
Question by
lightnarcissus · Aug 29, 2016 at 05:19 PM ·
event triggeringmultithreadingevent-handling
EventHandler from external DLL not firing in MonoBehaviour C# script
I am using a DLL which has an EventHandler that goes by something like this
#External.DLL event EventHandler SomeDataReceived;
After including this in Plugins folder in my Assets and adding it to my MonoBehaviour script as
using External.DLL
//inside the class
object.SomeDataReceived+= OnSomething;
protected virtual void OnSomething(object sender, SomeDataEventArgs e)
{
Debug.Log("something happened" + e.EventData);
}
Yet, it never fires. Am I doing something wrong? I've tried doing everything from creating a delegate eventhandler in the C# script, but I need some way to know when the eventhandler inside the DLL is getting fired.
One note: I am using a SynchronizationContext as one of the DLL's functions requires this, but from what I've heard Unity only works on a "single thread" (I might be wrong?), this might mean the MonoBehaviour script won't be able to pick up any events on an external thread. Also, this works perfectly fine if I were to use similar C# logic to make a WPF-form, so I assume it is something Unity-specific I'm missing.
Comment