Custom Asset Types
Custom assets are things you can define yourself. They give you a nice inspector window and they're hotloaded in-game, which means you can whip things up pretty quickly if you're using them.
Let's say you wanted your own custom weapon asset type. Here's how you'd do that.
Make a folder in your addon's root directory, call it
config. Make a file in there called
The file name you choose here will be the name for the base class and the extension for any files of this type.
Writing the FGD here is similar to how you'd write an FGD normally.
When writing these, give your fields some sane default values to make it easier on yourself.
You can obviously do a lot more than this - you could define all of the possible parameters here - but we'll keep things simple for now.
You then need to mirror this class in code. Make sure you specify the same defaults that you specify in the FGD.
Now that you have everything set up, you can use the inspector tool to edit your first weapon.
- Click the "Inspector" icon in the asset browser.
- Pick your asset type.
- Set up your weapon however you want.
- Save your asset into your addon's config directory - call it "MyWeapon.weapon"
Loading an asset type is super easy.
Congrats, you can now get your weapon's data using the WeaponData object you just created. For example:
You can edit these values in the inspector and they'll apply in-game as soon as you hit save with no extra work required.