Sign in


class SCILLThreadSafety : MonoBehaviour


Our Unity SDK is (partly) running on other threads. The real time message system based on MQTT runs on its own worker thread. As you cannot access Unity APIs from another thread, this class implements a static Queue that you can use to dispatch Unity code inside callback functions.

Just derive a new class from this class and use this code to dispatch code that should be run in the Update function

// Make sure we run this code on Unitys "main thread", i.e. in the Update function
RunOnMainThread.Enqueue(() =>
    // This call will be run in the next Update cycle

It’s required that the Update function of your class is not implemented, at least you must call the base Update function in your own implementation so that code that is dispatched to the queue also gets executed.

SCILLBattlePassManager and SCILLPersonalChallenges are both derived from this class.



protected static readonly ConcurrentQueue<Action> RunOnMainThread = new ConcurrentQueue<Action>();

A static queue that you can use to dispatch code that will be running in the next update cycle.