ModAssetBundle class
A loaded asset bundle (ModAssets.LoadBundle). Asset names are full lowercase paths as reported by Unity, such as assets/ui/panel.prefab; Load also accepts the file name alone, such as Panel.
public sealed class ModAssetBundle : IDisposableProperties
AssetNames
public IReadOnlyList<string> AssetNames { get; }The full paths of all assets in the bundle, such as assets/ui/panel.prefab.
IsLoaded
public bool IsLoaded { get; }Whether the bundle is still loaded, that is, it has not been unloaded by Unload or by the game.
Name
public string Name { get; }The bundle's file name, or (from memory) for a bundle loaded from bytes.
Methods
Contains(string)
public bool Contains(string name);Returns whether the bundle contains an asset with the specified name or path.
Dispose()
public void Dispose();Unloads the bundle without unloading the assets loaded from it (see Unload).
Load<T>(string)
public T Load<T>(string name) where T : class;Loads an asset by name (Panel) or path (assets/ui/panel.prefab) as the specified type, for example a prefab as GameObject, or an image as Texture2D or Sprite.
Type parameters
T: A Unity object type:UnityEngine.Objector a derived type.
Exceptions
KeyNotFoundException: The bundle contains no asset with that name and type.
LoadAll<T>()
public T[] LoadAll<T>() where T : class;Loads all assets of type T in the bundle; all assets for UnityEngine.Object.
LoadWithSubAssets<T>(string)
public T[] LoadWithSubAssets<T>(string name) where T : class;Loads an asset and its sub-assets of type T, such as the sprites in a texture or the meshes in a model. Returns an empty array if the asset does not exist.
ToString()
public override string ToString();A description for logs.
Unload(bool)
public void Unload(bool unloadAssets = false);Unloads the bundle. Assets already loaded from it remain loaded unless unloadAssets is true, in which case they are destroyed and objects still using them show missing textures or meshes. Has no effect if the bundle is already unloaded.