Asset Replacement

From A Hat in Time Wiki
Jump to navigation Jump to search

Asset Replacement is the technique of swapping assets of the same class. For example Textures, Materials, Models, SoundCues, Particles etcetera. Asset Replacement might cause an unexpected conflict with other mods depending on the replacement amount.

Asset Replacement happens on load of the mod and are permanently active, you can disable the replacement by creating a script extending GameMod with a class which gives you the ability to toggle the mod from the mod menu.

Procedure

The Assets and Content menu.

Go to the Assets and Content Menu in there you will see all the assets that are for the mod for Content Packages and Asset Replace, the latter is our focus.

The Asset Replace section takes two inputs the Target Asset and the New Asset. Both inputs take a path to an asset and to get that path you need to it from the Content Browser through the Editor, the assets must be the same class, e.g. you CANNOT replace a sound with a texture only with other sounds.

Asset Hierarchy

Because Asset Replacement focuses on changing a specific asset with a different one, some assets like textures are replaced, however, when a material relies on the original texture is also replaced you might get unexpected results, if this happens then you need to make a custom material that replaces every instance of that material and use that to replace those to get the result you want to achieve.

Example: Material_1 relies on Texture_1 | Texture_1 is replaced with Texture_2

Result: Material_1 relies on Texture_2


Example: Same as the above | Material_2 relies on Texture_3 | Material_1 is replaced with Material_2.

Result: Material_1 is replaced with Material_2 which relies on Texture_3.

Step by Step

The Content Browser

1) Open the Editor

2) click "View" -> "Browse Windows" -> "Content Browser".

3) In the content browser you can search every asset found in the game, you can filter out search results by Object Type and name in the search bar.

4) Find an asset you want to replace, right click then click "Copy Full Name to Clipboard" then go back to Asset Replace menu in the Modding Tools and paste it in Target Asset.

5) Similar to "4)" do this for New Asset, make sure both assets are the SAME TYPE!

6) Click "Save Changes"

7) Unless you have a GameMod the modding tools will generate GameMod class named in the format of [MOD_FOLDER_NAME]_AutoGenGameModClass, example: example_mod_AutoGenGameModClass.

8) Go to the Script Page and compile the GameMod script.

9) Go to the Upload Page and click "Cook Mod".

And done! Your mod will automatically have the "Asset Replace" tag added to it. You can now open the game and find where that asset is used and it will be automatically replaced with that content.

Few more things, all of the asset replacement assets are saved in your modinfo.ini which is loaded by your GameMod to handle everything for you, there's no way to dynamically add asset replacement on run time.

And like was said at the beginning Asset Replacement by design are risk of mod conflict if some mods or reliant on finding types that are being replaced by Asset Replacement. Despite this Asset Replacement are still easy to make and use.

Video

Credits: Donficient

Example Mods