Skip to Main Content

Custom Textures and Displays


This guide will cover both the inclusion of custom .png files to your mod and custom / modified 3D Models

Custom Textures

Including the PNGs

This section only applies anymore if you aren't following the mod template / didn't use the Create Mod button

To make sure that your non-code files actually end up being included inside your .dll mod file, you need to change the way your C# project treats them.

Screenshot of changing build action to embedded resource

Right click on the file you want to include (probably a .png unlike the image) and go to Properties.

Find the "Build Action" property and set its value to be "Embedded Resource".

Now, when you build your project, the .png will be included in the .dll as a resource that the Mod Helper can work with.

Using the Textures

The best way to access your textures once you've included them as resources is using methods found in the ModContent class. (read more about that here).

If you're working in a class that extends ModContent, then you can use some of the non-static methods like GetTextureGUID(string name), GetSpriteReference(string name), GetTexture(string name), and GetSprite(string name) that return your texture in various forms that you might need it in.

For all of those methods, the name parameter is the file name of your image without the .png file extension.

If you're working somewhere outside of a class extending ModContent, then you'll use the equivalent static ModContent methods like ModContent.GetTexture<T>(string name) where T is your BloonsTD6Mod extending class. You have to specify the Mod class for these static methods in order for it get to the correct internal ID for it.

ModDisplay

The ModDisplay class provides for an easy way to use modified versions of existing 3d Display Models, or fully custom 2D Display Models.

When you create your own class that extends ModDisplay, it will prompt you to override one Property and 1 Method.

Required Properties

BaseDisplay: Similar to the BaseTower property of ModTower, this is the Display that will be copied for your display. This is a GUID, so you can either just copy that in directly if you know it, or do something like public override string BaseDisplay => Game.instance.model.GetTower(TowerType.DartMonkey).display.GUID; There's also constants like Generic2dDisplay that you could use.

ModifyDisplayNode(UnityDisplayNode node): Code to modify your base display node however you like.

The most two most common things you'd do for a simple modified node would be:

Set2DTexture(node, Name); to set a 2D Display Models texture to be the a .png with the same name as your ModDisplay class.

or

SetMeshTexture(node, Name) to set the main texture of the Node's SkinnedMeshRenderer to be a .png with the same name as your ModDisplay class.

To get the .png files to edit for custom mesh textures, you can either use something like AssetStudio to get them from the game files yourself or just use the Mod Helpers extension method to do node.SaveMeshTexture(). You can specify the file path you want for the image, or if you leave it blank it will save to your local Bloons files at C:\Users[name]\AppData\LocalLow\Ninja Kiwi\BloonsTD6

Applying ModDisplays

The easiest way to use your display is through our ApplyDisplay<T>() extension methods present on things that you'd be using them for like TowerModels, ProjectileModels or just DisplayModels.

Note that for Towers, there's a special ModTowerDisplay class you ought to use that you can read about here.

Fully Custom Displays

Using Custom 3D models from outside the game requires more Unity knowledge than this tutorial covers at this time. However, if you are already in a situation where you have a Unity AssetBundle that contains Prefabs for your displays, then you can follow these instructions to use them very simply.

Including the AssetBundle

Set your bundle to have the file extension .bundle and have it within your project. Mod Helper will automatically handle loading from it as an embedded resource.

ModCustomDisplay

The ModCustomDisplay class (or ModTowerCustomDisplay) is what will let you use your custom displays. The two required properties are simply:

AssetBundleName: The name of your asset bundle file (without the ".bundle" part)

PrefabName: The name of your Prefab within the bundle (case sensitive)

Other class members you you can utilize are

MaterialName: Set this to automatically apply a material from your bundle with the given name to your display

ModifyDisplayNode: As with normal displays, you can modify the result display node with this

Example that loads the prefab "MyModel" from "assets.bundle"

public class MyCustomDisplay : ModCustomDisplay
{
    public override string AssetBundleName => "assets"; // loads from "assets.bundle"
    public override string PrefabName => "MyModel"; // loads the "MyModel" prefab
    
    public override void ModifyDisplayNode(UnityDisplayNode node)
    {
        // modify the node however you want
    }
}

You can then apply this display using the standard ApplyDisplay methods as normal.

To learn how to download BTD Mod Helper and install mods, click here