I’m working on a native plugin and I noticed there is a IUnityEventQueue
interface in the plugin API.
The comments in the file show how to create and send events in C++ and how to receive events in C++ but how can I use this interface to send events to a C# components?
I have a long running function in the native plugin that needs to run in a separate thread to avoid hanging the Unity editor (or the application at runtime). I want to setup a progress handler to send progress updates to C# and display a progress bar to the user. I was hoping I can use the event queue for this, but I can’t figure out how to receive those messages in C# land…
Maybe I’m just too noob and there is an obvious solution for Unity experts, but I’m just not seeing it…
Any help would be appreciated 
I also wondering about the GlobalEventQueue
mentioned in the comments:
MyEvent evt;
GlobalEventQueue::GetInstance().SendEvent(evt);
I can’t find any mention of this GlobalEventQueue
anywhere in the Plugin API!?
In the comments is also states:
// GUID definition for a new event.
//
// There is a tool to compute these, run the tool on the name of your
// message and insert the hash/type combination in your header file.
// This defines the EventId for your event payload (struct)
// Use this for events that do not require a destructor.
#define REGISTER_EVENT_ID(HASHH, HASHL , TYPE)
Where is this tool to compute the GUID?
From the comments in the header file and C# bindings it sounds like the purpose of
IUnityEventQueue is opposite from what you are asking.
I wouldn’t be surprised if the tool refers to UnityEventQueueSystem.GenerateEventIdForPayload C# method UnityCsReference/Runtime/Export/UnityEvent/UnityEventQueueSystem.bindings.cs at d76ca0c1f57f36891cb231ed36e80a795d9244d2 · Unity-Technologies/UnityCsReference · GitHub All it does is generates unique GUID and formats it so that you can copy paste that line of text.
I interpreted that as you don’t need to bother with managed systems in your native plugin.
Thanks for the link to the UnityEventQueueSystem… Now I just need to figure out how to use it in the native plugin…
@karliss_coldwild Do you have any hints about how I can use the GlobalEventQueue::GetInstance()
in C++?
Nevermind… I’m giving up on this option.