The asset management system.
Asset data
is the nickname of a collection of scripts that for a system initially introduced by Seteron, it beingb v a way to get assets in a more practical manner than using Resources
.
Load
(
"AssetName"
)
.
With Asset data
, however we use static classes
with the corresponding to the asset name, so finding an asset is a manner of knowing the asset name in order to load it.
This system is very experimental, we are still seeing if this makes sense to use and if this is the best alternative. Please report issues.
If the database is renamed, the old generated class is not deleted.
The new way of referencing DatabaseAssets via WorldObjectReferences only works for GameObjects (by design). Ideally this should be separated by type or category, and have a way to not depend on guids, I was thinking on testing some stuff with the localization table for ids.
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.
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.
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.
To use an existing asset database, simply look for its file by "Assets/Scripts/SS3D/Data/Generated"
, find the database you want to use and then call the item you want to grab.
Some of these examples have implicit operators to cast them into the correct type. You have to manually add the implicit operators, for now.
Create an AddressableGroup for your assets. (
Window/AssetManagement/Addressables/Groups
)
.
Set your assets as addressabble and in the groups menu drag them to your new group.
Go to the Assets/Content/Data/Databases
folder, and create a new AssetDatabase by going to Create/SS3D/AssetDatabase
.
Set your AddressablesGroup in the inspector.
Go to ProjectSettings/SS3D/Assets/AssetDatabaseSettings
Press find and load asset databases.
Check if your new database code was generated in the Assets/Scripts/SS3D/Data/Generated
folder