- Home /
IUnityEventQueue - how do I use it?
I am currently writing a C++ native plugin for my Unity application.
I've came across the IUnityEventQueue.h file in the UnityPluginAPI folder, but documentation is pretty thin on the ground - do some docs and/or examples exist for writing native plugins that use it?
What I want to do is; issue an event from my Unmanaged code that is then picked up on the Unity main thread in Managed code - is this possible? Currently I am achieving this with Unmanaged->Managed callbacks, but I would prefer to use a more robust solution if one exists. From the comments in the IUnityEventQueue.h file, this sounds like it may be possible, but there are no examples of how to achieve this.
neither google nor any search engine spit out something else than this question and your forum post about IUnityEventQueue. So I'm pretty sure the way plugins are supposed to be created is like the processes described in the manual pages.
While I can definitely do what I want by handing callbacks myself, the comments in the IUnityEventQueue file seems to suggest that it is designed for exactly the scenario I want to use it for;
-5.2 patch 1 + of Unity will support this. The Unity EventQueue is a standard way of passing information between plugins or parts of the engine without any reliance on managed systems, game objects or other pieces of Unity. Events are simply a structure and GUID pair. GUIDs were chosen rather than hashes as it allows plugins to define their own event payloads and use the EventQueue. While the EventQueue itself is self contained and can be used for many different applications within Unity the global event queue that is passed to plugins is always serviced on the main simulation thread and thus serves as a convenient means of pushing asynchronous operations back to the main game thread
Since there is no manual page, perhaps it is a feature that is not yet ready for a full release?
Answer by yi-li · Apr 28, 2017 at 05:52 AM
You are on the right track, the IUnityEventQueue.h described everything you need know to use it. RegisterEvent
Fire when you want
use static class based eventhandler to catch these events (pass to main thread etc...)
Answer by bleater · Jul 17, 2020 at 05:04 AM
The comments in the header make explicit mention of a "global event queue", even naming it in the UnityEventSystem namespace GlobalEventQueue::GetInstance ().SendEvent (evt);
. But it doesn't appear anywhere in the header, so I'm mystified how this is supposed to work.
Your answer
Follow this Question
Related Questions
Distribute terrain in zones 3 Answers
formatting errors converting this code! 2 Answers
DirectX11 get handle to Unity Swapchain/Backbuffer 0 Answers
Access Unity Script Function From External Program 1 Answer
Using Native C++ dll in Unity 1 Answer