Changes

Jump to navigation Jump to search
no edit summary
Line 44: Line 44:     
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 OnDeactivate methods, to signal when the mod is toggled. 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 OnDeactivate 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 ModBehaviour's 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 ==
Line 88: Line 85:  
The game will define 3 symbols SWINC'''TYPE''' (SWINCBETA or SWINCRELEASE), SWINCTYPE'''MAJOR''' (SWINCBETA1, SWINCBETA2, etc.) and SWINCTYPEMAJOR'''_MINOR''' (SWINCBETA1_7, SWINCBETA1_8, etc.)
 
The game will define 3 symbols SWINC'''TYPE''' (SWINCBETA or SWINCRELEASE), SWINCTYPE'''MAJOR''' (SWINCBETA1, SWINCBETA2, etc.) and SWINCTYPEMAJOR'''_MINOR''' (SWINCBETA1_7, SWINCBETA1_8, etc.)
   −
= Saving and loading data =
+
= Getting Started =
== Global data ==
+
== Note on threading ==
 +
You should stick to the ModBehaviour's 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.
 +
 
 +
== Saving and loading data ==
 +
=== Global data ===
 
All '''ModBehaviours''' have '''SaveSetting''' and '''LoadSetting''' methods to save data globally.
 
All '''ModBehaviours''' have '''SaveSetting''' and '''LoadSetting''' methods to save data globally.
   Line 98: Line 99:  
There's also '''TryLoadSetting''', if you want to handle when the setting doesn't exist and '''DeleteSetting''' to remove existing settings.
 
There's also '''TryLoadSetting''', if you want to handle when the setting doesn't exist and '''DeleteSetting''' to remove existing settings.
   −
== Per save data ==
+
=== Per save data ===
 
You can also save data to the player's save file, to keep settings per save, by overriding your '''ModBehaviours'''' '''Serialize''' and '''Deserialize''' methods. These use a '''WriteDictionary''', which is just a dictionary of whatever you want, and the game will handle turning it into bits.
 
You can also save data to the player's save file, to keep settings per save, by overriding your '''ModBehaviours'''' '''Serialize''' and '''Deserialize''' methods. These use a '''WriteDictionary''', which is just a dictionary of whatever you want, and the game will handle turning it into bits.
   Line 111: Line 112:  
Note that your the save data is identified by the '''Name''' you've set in the '''ModMeta''' class. If you change this name, it will no longer be able to find the correct data from older saves and name clashes will result in data loss.
 
Note that your the save data is identified by the '''Name''' you've set in the '''ModMeta''' class. If you change this name, it will no longer be able to find the correct data from older saves and name clashes will result in data loss.
   −
== Reading external data ==
+
== Reading external files ==
 
Finally, all modbehaviours have access to their '''ParentMod''', this is the class that manages your mod, and through this you can load files using the methods '''LoadTexture'''(png, jpg, jpeg), '''LoadTydFile'''(tyd), '''LoadAudio'''(mp3, wav, ogg), '''LoadGLTF'''(gltf, glb) and '''LoadOBJ'''(obj). Note that these methods all use relative paths from where your mod is installed and using '''../''' won't work.
 
Finally, all modbehaviours have access to their '''ParentMod''', this is the class that manages your mod, and through this you can load files using the methods '''LoadTexture'''(png, jpg, jpeg), '''LoadTydFile'''(tyd), '''LoadAudio'''(mp3, wav, ogg), '''LoadGLTF'''(gltf, glb) and '''LoadOBJ'''(obj). Note that these methods all use relative paths from where your mod is installed and using '''../''' won't work.
  

Navigation menu