Changes

Jump to navigation Jump to search
222 bytes added ,  10:47, 16 June 2020
no edit summary
Line 39: Line 39:  
</pre>
 
</pre>
   −
ModBehaviours are just a subclass of Unity's [https://docs.unity3d.com/2017.4/Documentation/ScriptReference/MonoBehaviour.html MonoBehavior] and work the same way, i.e. they use the same life cycle of Awake, Start, Update, OnDestroy, ModBehaviours only differ in that they have the abstract OnActive and OnDeactive methods, to signal when the mod is toggled. You should stick to the Update method, rather than trying to write your own update loop, as you cannot interact with Unity's system from other threads. Each ModBehaviour implementation will be instantiated once the mod is loaded.
+
ModBehaviours are just a subclass of Unity's [https://docs.unity3d.com/2017.4/Documentation/ScriptReference/MonoBehaviour.html MonoBehavior] and work the same way, i.e. they use the same life cycle of Awake, Start, Update, OnDestroy, ModBehaviours only differ in that they have the abstract OnActive and OnDeactive methods, to signal when the mod is toggled. Each ModBehaviour implementation will be instantiated once the mod is loaded.
 +
 
 +
== Note on threading ==
 +
You should stick to the Update method, rather than trying to write your own update loop with threads or timers, as you cannot interact with Unity's system from other threads and you will most likely end up causing race conditions when interacting with the game's systems. You can use Unity's Time class to keep track of elapsed time between frames.
    
== Compile ==
 
== Compile ==

Navigation menu