Click or drag to resize

Loading a mod

Available Mods can easily be loaded and unloaded. Loading a mod loads the Mod's Assemblies and assets so they can be used in the game.

Loading Mods can be done asynchronously. Both the ModManager and Mods provide events for when they're loaded, unloaded or when async loading has been cancelled.

Loading and unloading

Load a mod with Mod.Load() or Mod.LoadAsync(). When a Mod has finished loading, Mod.Loaded and ModManager.ModLoaded will occur.

To unload a mod, use Mod.Unload(). Because Mods can be loaded asynchronously, a Mod could still be loading when Unload is called. In this case, unloading will be queued untill it can be unloaded, or when Load is called again. When a Mod has unloaded, Mod.Unloaded and ModManager.ModUnloaded will occur.

Mod.isEnabled can be used to keep track of which mods a user wants to enable or disable. This property does not affect what you can do with a Mod; a Mod that is not enabled can still be loaded. This property is saved in the Mod's modInfo. With Mod.ConflictingModsEnabled() you can check if any conflicting mods are enabled as well. A Mod can not be loaded when another conflicting Mod is loaded.

Loaded Mods

Once a Mod has been loaded, you can use its resources. These are the assets, scenes and Types in any of the Mod's Assemblies.

Scenes are wrapped in the ModScene class, to make them easy to handle and load in a similar way as Mods.

Included prefabs are accessible through Mod.prefabs. Prefabs should be instantiated through the Mod's contentHandler. This will initialize any scripts on the prefab.

When a Mod is unloaded while its scenes are still loaded, the scenes will be unloaded. Instances of prefabs and components that are still in use will be destroyed.

It is a good practice to make sure instances of prefabs and GameObjects created by the Mod are accounted for by either the modder or the game. By default, ModTool will enfore the use of its own Instantiate and AddComponent methods that make sure this gets handled.