AssetBundle
An AssetBundle is a packaged collection of resources.
Notes:
An AssetBundle is generated by packaging resources using the Spatial Editor. It helps compress and manage resources efficiently.
A Model corresponds to a scene description file (typically a Scene in the Spatial Editor), usually saved in the project as a USD file.
The model input path examples:
Scenes/Scene.usda -> Scene name: Scene (default case)
Scenes/Sub/Scene.usda -> Scene name: Sub/Scene
Scenes/Sub/Sub/Scene.usda -> Scene name: Sub/Sub/Scene
Example Usage
// Load an AssetBundle
val assetBundle = AssetBundle.load("asset://AssetBundles/MyAssetBundle.bundle")
// Load a model from the AssetBundle
val model = assetBundle.loadModel("Sub/Sub/Scene")
// Load a material from the AssetBundle
val material = assetBundle.loadMaterial("Sub/Sub/Scene/MyMaterial/NewMaterial")
// Release model and material resources
assetBundle.releaseModel("Sub/Sub/Scene")
assetBundle.releaseResource("Sub/Sub/Scene/MyMaterial/NewMaterial")
// Close the AssetBundle when it is no longer needed
assetBundle.close()Types
The companion of AssetBundle.
Properties
The AssetBundle is valid.
Functions
Closes an AssetBundle and releases the resources occupied by it.
Asynchronously loads an audio resource from a relative path.
Asynchronously loads an audio resource from a relative path.
Loads a material from the specified path.
Loads a mesh resource from the specified path.
Asynchronously loads a model by its name. This is a suspend function.
Loads a texture resource from the specified path.
Preloads the specified model into memory.
Releases a previously loaded model by its name.
Releases a previously loaded resource at the specified path.