System that manages loading and unloading assets.
Some of these functions are available as global functions, so you can just call LoadAsset(name)
instead of AssetManager.LoadAsset(name)
. See Globals.
Unload any assets that are no longer referenced.
Sig: AssetManager.RefSweep()
Get an asset by name. Does not load it. Will return nil if the asset hasn't been loaded.
Sig: asset = AssetManager.GetAsset(name)
- Arg:
string name
Asset name - Ret:
Asset asset
Asset
Load and get an asset immediately.
Sig: asset = AssetManager.LoadAsset(name)
- Arg:
string name
Asset name - Ret:
Asset asset
Loaded asset
Save an asset. Only available in Editor.
Sig: AssetManager.SaveAsset(name)
- Arg:
string name
Asset name
Request that an asset be loaded asynchronously. This function will return a reference to an asset, and you can check if it has been loaded. Call asset:IsLoaded()
to see if it has been loaded. TODO: Add function callback to handle when asset is loaded.
Sig: asset = AssetManager.AsyncLoadAsset(name)
- Arg:
string name
Asset name - Ret:
Asset asset
Pending asset
Unload an unreferenced asset.
Sig: AssetManager.UnloadAsset(name)
- Arg:
string name
Asset name
Create an asset of a given type.
Sig: asset = AssetManager.CreateAndRegisterAsset(typeName, path, name)
- Arg:
string typeName
Name of the type to create (e.g. MaterialLite) - Arg:
string path
Where the asset should be saved - Arg:
string name
Name of the new asset - Ret:
Asset asset
The newly created asset