Show / Hide Table of Contents

Class ModAssetBundle

An asset bundle mod resource.

Some care must be taken when using this class, see the Remarks section for details.

Inheritance
Object
ModResource
ModAssetBundle
Inherited Members
ModResource.GetTexture(String)
ModResource.GetMesh(String)
ModResource.GetAudioClip(String)
ModResource.GetAssetBundle(String)
ModResource.Get(ResourceReference)
ModResource.CreateTextureResource(String, String, Boolean, Boolean)
ModResource.CreateMeshResource(String, String, Boolean)
ModResource.CreateAudioClipResource(String, String, Boolean)
ModResource.CreateAssetBundleResource(String, String, Boolean)
ModResource.SetOnObject(GameObject, Action<GameObject>, Action)
ModResource.TriggerOnLoad()
ModResource.AllResourcesLoaded
ModResource.Type
ModResource.Name
ModResource.Available
ModResource.OnResourceLoaded
ModResource.OnAllResourcesLoaded
Namespace: Modding
Assembly: Assembly-CSharp.dll
Syntax
public class ModAssetBundle : ModResource
Remarks

Sometimes all assets of an AssetBundle are unloaded by Unity if the bundle hasn't been used for a while after it was first loaded.

The recommended way of using this class is to access the AssetBundle property to load any assets directly from an OnLoad callback. This will ensure that the bundle is correctly loaded at that point.

If you must access the bundle outside of the OnLoad callback and you or players run into issues where the bundle suddenly claims the assets you want to load are not present, use the LoadAsset wrappers of this class instead. They will reload the bundle when necessary, but this can incur a hit on framerate, so use OnLoad instead whenever possible.

Properties

AssetBundle

Declaration
public AssetBundle AssetBundle { get; }
Property Value
Type Description
UnityEngine.AssetBundle

Error

Declaration
public override string Error { get; }
Property Value
Type Description
String
Overrides
ModResource.Error

HasError

Declaration
public override bool HasError { get; }
Property Value
Type Description
Boolean
Overrides
ModResource.HasError

Loaded

Declaration
public override bool Loaded { get; }
Property Value
Type Description
Boolean
Overrides
ModResource.Loaded

Methods

LoadAsset<T>(Int32)

Returns the asset with the given index from LoadAllAssets, possibly reloading the bundle.

Use this only when necessary, see the Remarks section of the class documentation for more details.

Declaration
public T LoadAsset<T>(int index)
    where T : Object
Parameters
Type Name Description
Int32 index
Returns
Type Description
T
Type Parameters
Name Description
T

LoadAsset<T>(String)

Returns the asset with the given name, possibly reloading the bundle.

Use this only when necessary, see the Remarks section of the class documentation for more details.

Declaration
public T LoadAsset<T>(string name)
    where T : Object
Parameters
Type Name Description
String name
Returns
Type Description
T
Type Parameters
Name Description
T

Events

OnLoad

Called when the resource has finished loading.

This is also called if there was an error loading the resource.

If a new handler is added to this and the resource has already finished loading, it is immediately called.

Declaration
public override event Action OnLoad
Event Type
Type Description
Action
Overrides
ModResource.OnLoad

Operators

Implicit(ModAssetBundle to AssetBundle)

Declaration
public static implicit operator AssetBundle(ModAssetBundle bundle)
Parameters
Type Name Description
ModAssetBundle bundle
Returns
Type Description
UnityEngine.AssetBundle
Back to top Generated by DocFX