How Asset Data works

The AssetData system is divided in a few classes:

Assets

  • This class caches all the AssetDatabases in the game, its where we retrieve the asset we want. We can use the getters to specify which asset from a database to retrieve it.

DatabaseAsset

  • A class that contains a reference for the Name and DatabaseName of an asset, this is used to load them in a convenient way as the class is used when we generate the database code.

AssetDatabase

  • ScriptableObject that loads all assets present on an AddressablesGroup, adding them to a list of assets and generating a static class with DatabaseAssets related to those assets.

WorldObjectAssetReference

  • A class used for world object assets, assets that can be placed in the world as a GameObject, this has the purpose of creating a way to reference database assets via the inspector, without having to look for a prefab, it is also generated by the asset data system.

AssetDatabaseSettings

  • a ScriptableSettings class that loads all the AssetDatabases. Everything here is automated, you don't have to mess with. Its useful to see if all the databases are loaded, or to ignore code generation.

The system will automatically load all databases and generate the code/assets for it when a project reload is triggered or when the UI for the settings is opened.

How it works

Whenever the code/asset generation is triggered, the system will scan for asset databases that are not loaded, load them in the list and then start the generation process.

The generation process simply iterates through each database and generate a static class of an DatabaseAsset for each item in the database.

This is an example of a generated class.

The system will also generate a bunch of WorldObjectAssetReferences, this is done on all assets that can be cast to GameObjects, they can be used in the inspector to reference an database asset.

Last updated