About this mod
Allows dynamic runtime replacement of TextAssets in Unity games
- Requirements
- Permissions and credits
Requires Unity Mod Manager
Description
INIfier allows you to replace the content of a Unity TextAsset without updating/replacing the asset files themselves. This is mostly useful for developers that would need to replace TextAssets as part of their mods, and is not geared towards the end user. Despite this it could still be useful to users, for example if there is display text stored within a TextAsset that they would like to translate to another language.
Normally this would require updating the .assets files from the game and distributing the updated files or a patch, which may need to re-developed and distributed with each new game update. Using INIfier, as long as the name of the asset doesn't change, you can continue using the same replacement file between any game version. And as long as the file isn't overwritten or removed, it doesn't need to be re-created on every launch or game update.
Installation (for end users)
Install Unity Mod Manager for the target game. Add the .zip file from this mod into Unity Mod Manager. The mod will be enabled by default, but can be toggled using the UMM menu in game (default Ctrl+F10 to open/close). If enabled the mod will replace the text/bytes any time they are read from the TextAsset, if disabled then reading the text/bytes will return the original content. If the text from the TextAsset is stored in another variable or otherwise cached instead of being re-read from the asset each time, only the initial read will be handled by INIfier.
Usage (for mod authors)
Reference the .dll in your project to use the INIfier methods. An .xml file is also included to provide intellisense for the available methods.
There are 2 ways to replace a file
- Provide the replacement .ini file with the mod so the user can place it in the INIfier/Assets directory
- Register the replacement file programmatically
You can also use INIfier to check for the existence of a given found/replacement file, and get its contents. Used carefully, this allows multiple mods to update the same TextAsset by only modifying the affected part of the file, rather than each mod overwriting any previous changes.
The replacement string or byte array is stored in an .ini file, under the Assets folder inside the INIfier mod directory created by Unity Mod Manager. As long as you use the INIfier methods to manipulate replacement files, you don't have to care about the actual location of the Assets folder.
The file will be used instead of the "text" or "bytes" properties on the TextAsset instance. Each TextAsset has a name, and this must be the name of the replacement file. If no replacement file exists, INIfier will create a .found file (but will not overwrite an existing .found file) with the same name as the TextAsset, and place the contents inside it. Depending on whether the "text" or "bytes" property was called, the .found file will either be written as a string or a byte array. All files using the "text" property will be read/written as UTF8.
You can add a requirement for INIfier in your mod info json file. You must use the id of INIfier rather than the name. There are 3 spaces in front of the ID (as mods are loaded alphabetically, this helps INIfier patch the relevant methods before anything else may use a TextAsset) so use the string " INIfier-1.0.0"