Custom Assets!



Click image to return to Home



Custom Assets

Using the principles learnt in the Creating Old World Mods tutorial, this tutorial will take you through the process of adding in custom assets. This functionality was added to Old World at the end of June.

Setting up Unity

Old World is built on Unity. Assets are loaded into Unity games via asset bundles. These are packages of assets that the game uses, sort of like a zip or cabinet file. To add our own custom assets to the game, we need to create our own asset bundle. But first, we need to install Unity.

I won't take you step by step through how to install Unity as there are plenty of tutorials on the Unity website for that already. All you need to do, is start here:

Old World is built on version 2019.4.1f1 LTS (Long Term Support). For the sake of compatibility, I suggest installing the same version.

Once Unity is installed, create a new project.


The first thing to do is to add your image to Unity. I've added cool red sunnies to my leader.

Within Unity we need to configure our image for Old World. Click on your image and in the Inspector ensure that your image texture type is Sprite (2D and UI) and sprite mode is Single. Unity will automatically setup the sprite ready for Old World. Note: if you set sprite mode to multiple you can define multiple sprites on a single sprite sheet. This is an advanced concept and refer to Unity documentation on how to do this.

Asset Bundle

Once you have some assets in Unity, you need to package them in an asset bundle for the game. Asset bundles are basically Unity's way of packaging assets into manageable containers for use within games. Old World has been setup to allow custom asset bundles within the mods folder.

Add an "Assets" folder to your mod's folder. EG: OldWorld_Data\StreamingAssets\Mods\Byzantine Empire\Assets\

There are a number of ways to create asset bundles in Unity. One way is to use the Unity Asset Bundle Browser Tool which is available here: Unity Asset Bundle Tool.

Another simple method is to include a short script to create asset bundles. To do this, within Unity in the Editor folder create a C# script. Name the script ExportAssetBundles.

Add the following code to the script.

using UnityEngine;
using UnityEditor;

public class ExportAssetBundles {
    [MenuItem("Assets/Build AssetBundle")]
    static void ExportResource () {
        string path = "The path to the game folder/OldWorld_Data/StreamingAssets/Mods/CustomAssets/Assets/MyAssetBundle";
        Object[] selection = Selection.GetFiltered(typeof(Object), SelectionMode.DeepAssets);
        BuildPipeline.BuildAssetBundle(Selection.activeObject, selection, path, 
                                     | BuildAssetBundleOptions.CompleteAssets, BuildTarget.StandaloneWindows);

NOTE1: put the current path to the game's files where required. You need to also ensure the correct mod folder is set.

NOTE2: this asset bundling script works on the premise that you select the assets to bundle, then run the script.

NOTE3: you access the script by opening the Assets menu and selecting Build AssetBundle.

Selecting this menu item should create your asset bundle ready to use in the game.

XML Updates

Now that we have an asset bundle in our mod folder, which contains our asset, it is time to make changes to the xml files so that our asset is used in game. For images you will need to add new images to assets-add.xml and add to spriteGroup-change.xml. As the new asset I'm adding is a character portrait, I also need to update the character's portrait to point to the new one.

Click image for full size

With all our xml configured, and our asset bundle created, there is only one last thing to do.

Play Assyria with our cool sunnies wearing Ashurbanipal.

That concludes this tutorial. You should now be able to create custom assets bundles for your mods.

Custom Assets - 29 June 2020