UnityMainThreadDispatcher
UnityMainThreadDispatcher copied to clipboard
Provides a simple, thread safe, non monobehaviour service for managing the queue of work items on unity main thread
Unity Main Thread Dispatcher
Installation
Requires Unity 2019+
Install via UPM (using Git URL)
https://github.com/gustavopsantos/unitymainthreaddispatcher.git?path=/Assets/UnityMainThreadDispatcher/#1.0.0
Install manually (using .unitypackage)
- Download the .unitypackage from releases page.
- Import UnityMainThreadDispatcher.X.X.X.unitypackage
After downloading or installing by package manager, thats it, since we rely on low level player loop system, theres no need for creating a gameobject in order to hook MonoBehaviour update method
Usage
UnityMainThreadDispatcher.Dispatcher.Enqueue(() => Debug.Log("This is happening on unity main thread"));