Skip to content

ModAssetBundle class ​

Namespace Lustral · Assembly Lustral.Api

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.

csharp
public sealed class ModAssetBundle : IDisposable

Properties ​

AssetNames ​

csharp
public IReadOnlyList<string> AssetNames { get; }

The full paths of all assets in the bundle, such as assets/ui/panel.prefab.

IsLoaded ​

csharp
public bool IsLoaded { get; }

Whether the bundle is still loaded, that is, it has not been unloaded by Unload or by the game.

Name ​

csharp
public string Name { get; }

The bundle's file name, or (from memory) for a bundle loaded from bytes.

Methods ​

Contains(string) ​

csharp
public bool Contains(string name);

Returns whether the bundle contains an asset with the specified name or path.

Dispose() ​

csharp
public void Dispose();

Unloads the bundle without unloading the assets loaded from it (see Unload).

Load<T>(string) ​

csharp
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.Object or a derived type.

Exceptions

LoadAll<T>() ​

csharp
public T[] LoadAll<T>() where T : class;

Loads all assets of type T in the bundle; all assets for UnityEngine.Object.

LoadWithSubAssets<T>(string) ​

csharp
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() ​

csharp
public override string ToString();

A description for logs.

Unload(bool) ​

csharp
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.

Mods are third-party software. Lustral does not verify their behavior and is not responsible for any damage they cause.