The ModKit provides a few basic assets, namely sprites for the buttons and panels.
However, you might need to use other assets in your mod.
Here is how you can retrieve and use those assets.
Programatically (advanced)
Finding the name of the asset
This part is a bit tricky and will require a LOT of digging on your part. You will need to find an element that has the asset that you want and print its name. You can either do a Harmony patch and override a method or check if the element implements a component referenced by a singleton class such as CanvasHandler.
An other way is to extract the assets and look them all up (see below)
Use Unity’s Resources class
Unity provides the Resources class to retrieve assets in the game. Any asset put into the “Resources” folder by the game’s developpers can be retrieve with Resources.Load(pathOfAsset);
All other assets need to be retrieved with Resources.FindObjectsOfTypeAll(pathOfAsset);
Load
Load will retrieve any asset that was put into the “Resources” folder in Unity by the devs. To load a resource, you need to provide a path to the Load or LoadAll method. There is unfortunately no way for us to know the folder hierarchy the devs used. You can however try to guess. For example, most sprites are in the “Sprites” folder.
Ex: Resources.Load(“Sprites/nameOfTheSprite”);
Otherwise, load all resources with an empty path and select the one you want:
Ex: Resources.LoadAll("").First(x=>x.name == nameOfTheSprite);
Note: As per the method description in the documentation, you might want to do a Resources. UnloadUnusedAssets after calling LoadAll to preserve memory. Please see the documentation of the Resource class.
FindObjectsOfTypeAll
This method can retrieve any object currently loaded by the game. If the asset you want to retrieve is not currently loaded in game, you will not be able to retrieve it. This method is used similarly to LoadAll except you don’t need to provide a path. Retrieve the asset you want by name:
Ex: Resources.FindObjectsOfTypeAll().First(x=>x.name == nameOfTheSprite);
Extract the game’s assets
Yes, it is entirely possible to extract the game’s assets, just like we can extract the code.
So long as the goal is to mod the game, extracting the assets is allowed.
To extract the assets, you will need a 3rd party tool such as AssetStudio. This tool is very easy to use. Simply boot it up and select the game’s Data folder (usually C:\Program Files (x86)\Steam\steamapps\common\Founders Fortune\Founders Fortune_Data).
Note: After some tests, it seems this tool can only load assets NOT in the “Resource” folder.
You can then extract them and edit the assets. Once edited, import them into the ModKit.
However, if you do not wish to edit those assets, do not add them back into the game through the ModKit. Use the Resources class instead if possible.
The reason is quite simple:
- Preserve the game memory. If 10 mods are all adding back the same asset unedited, that’s 10 new assets loaded into the game that are exactly the same.
- Mods overwrite each other. If 10 mods are re-adding the same file without renaming it, only one of the 10 files will be kept.