Table of Contents

Class TAssetBundles

Namespace
TAssetBundle
Assembly
TAssetBundle.dll

TAssetBundle integrated manager class Provides core functionalities of the TAssetBundle system, including asset initialization, catalog management, asset loading/unloading, scene transitions, downloads, etc.

public static class TAssetBundles
Inheritance
TAssetBundles
Inherited Members

Properties

Settings

Access system settings information.

public static Settings Settings { get; }

Property Value

Settings

Methods

CheckCatalogUpdateAsync()

Asynchronously checks if the default catalog needs to be updated.

public static TAsyncOperation<bool> CheckCatalogUpdateAsync()

Returns

TAsyncOperation<bool>

TAsyncOperation object that returns true if an update is required, otherwise false.

CheckCatalogUpdateAsync(string)

Asynchronously checks if the specified catalog needs to be updated.

public static TAsyncOperation<bool> CheckCatalogUpdateAsync(string catalogName)

Parameters

catalogName string

Catalog name

Returns

TAsyncOperation<bool>

TAsyncOperation object that returns true if an update is required, otherwise false.

DownloadAsync()

Asynchronously downloads the asset bundles from the default catalog.

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadAsync()

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

TAsyncOperationProgress object containing download progress and information.

DownloadAsync(string)

Asynchronously downloads the asset bundles from the specified catalog.

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadAsync(string catalogName)

Parameters

catalogName string

Catalog name

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

TAsyncOperationProgress object containing download progress and information.

DownloadByAssetsAsync(string[])

Asynchronously downloads the asset bundles containing the specified assets.

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadByAssetsAsync(string[] assetPaths)

Parameters

assetPaths string[]

Array of asset paths

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

TAsyncOperationProgress object containing download progress and information.

DownloadByAssetsAsync(AssetRef[])

Download files that need to be downloaded among the asset bundles used by the assets.

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadByAssetsAsync(AssetRef[] assetRefs)

Parameters

assetRefs AssetRef[]

asset references

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

asset bundle download info

DownloadByScenesAsync(string[])

Asynchronously downloads the asset bundles containing the specified scenes.

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadByScenesAsync(string[] sceneNameOrPaths)

Parameters

sceneNameOrPaths string[]

Array of scene names or paths

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

TAsyncOperationProgress object containing download progress and information.

DownloadByScenesAsync(SceneAssetRef[])

Download the files that need to be downloaded among the asset bundles used by the scene

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadByScenesAsync(SceneAssetRef[] sceneAssetRefs)

Parameters

sceneAssetRefs SceneAssetRef[]

scene asset references

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

asset bundle download info

DownloadByTagsAsync(string[])

Asynchronously downloads the asset bundles with the specified tags.

public static TAsyncOperationProgress<AssetBundleDownloadInfo> DownloadByTagsAsync(string[] tags)

Parameters

tags string[]

Array of tags

Returns

TAsyncOperationProgress<AssetBundleDownloadInfo>

TAsyncOperationProgress object containing download progress and information.

ExistAsset(string)

Checks if an asset at the specified path exists in the catalog.

public static bool ExistAsset(string assetPath)

Parameters

assetPath string

Asset path

Returns

bool

True if the asset exists, otherwise false.

ExistAsset(AssetRef)

Whether the asset exists in the catalog

public static bool ExistAsset(AssetRef assetRef)

Parameters

assetRef AssetRef

asset reference

Returns

bool

true if the asset exists, false otherwise

ExistScene(string)

Checks if a scene with the specified name or path exists.

public static bool ExistScene(string sceneNameOrPath)

Parameters

sceneNameOrPath string

Scene name or path

Returns

bool

True if the scene exists, otherwise false.

GetActiveAssetBundles()

Returns the currently active asset bundle information.

public static IEnumerable<IActiveAssetBundleInfo> GetActiveAssetBundles()

Returns

IEnumerable<IActiveAssetBundleInfo>

Collection of active asset bundle information.

GetDownloadSizeAsync()

Asynchronously returns the total file size of the asset bundles to download from the default catalog.

public static TAsyncOperation<long> GetDownloadSizeAsync()

Returns

TAsyncOperation<long>

TAsyncOperation object containing the total file size.

GetDownloadSizeAsync(string)

Asynchronously returns the total file size of the asset bundles to download from the specified catalog.

public static TAsyncOperation<long> GetDownloadSizeAsync(string catalogName)

Parameters

catalogName string

Catalog name

Returns

TAsyncOperation<long>

TAsyncOperation object containing the total file size.

GetDownloadSizeByAssetsAsync(string[])

Asynchronously returns the total file size of the asset bundles to download containing the specified assets.

public static TAsyncOperation<long> GetDownloadSizeByAssetsAsync(string[] assetPaths)

Parameters

assetPaths string[]

Array of asset paths

Returns

TAsyncOperation<long>

TAsyncOperation object containing the total file size.

GetDownloadSizeByAssetsAsync(AssetRef[])

Get the total size of the files that need to be downloaded out of the asset bundles required by the asset.

public static TAsyncOperation<long> GetDownloadSizeByAssetsAsync(AssetRef[] assetRefs)

Parameters

assetRefs AssetRef[]

asset references

Returns

TAsyncOperation<long>

file size

GetDownloadSizeByScenesAsync(string[])

Asynchronously returns the total file size of the asset bundles to download containing the specified scenes.

public static TAsyncOperation<long> GetDownloadSizeByScenesAsync(string[] sceneNameOrPaths)

Parameters

sceneNameOrPaths string[]

Array of scene names or paths

Returns

TAsyncOperation<long>

TAsyncOperation object containing the total file size.

GetDownloadSizeByScenesAsync(SceneAssetRef[])

Get the total size of the files that need to be downloaded out of the asset bundles required for the scene.

public static TAsyncOperation<long> GetDownloadSizeByScenesAsync(SceneAssetRef[] sceneAssetRefs)

Parameters

sceneAssetRefs SceneAssetRef[]

scene asset references

Returns

TAsyncOperation<long>

file size

GetDownloadSizeByTagsAsync(string[])

Asynchronously returns the total file size of the asset bundles to download with the specified tags.

public static TAsyncOperation<long> GetDownloadSizeByTagsAsync(string[] tags)

Parameters

tags string[]

Array of tags

Returns

TAsyncOperation<long>

TAsyncOperation object containing the total file size.

GetLastWebRequestError()

Returns the error information from the last web request.

public static UnityWebRequestError GetLastWebRequestError()

Returns

UnityWebRequestError

UnityWebRequestError containing the last web request error information.

GetLoadedAssets()

Returns the collection of all loaded asset information.

public static IEnumerable<IAssetInfo> GetLoadedAssets()

Returns

IEnumerable<IAssetInfo>

Collection of loaded asset information.

InitializeAsync()

Initializes the TAssetBundle system asynchronously. Even if not called explicitly, it will be automatically invoked internally.

public static TAsyncOperation InitializeAsync()

Returns

TAsyncOperation

TAsyncOperation object indicating initialization progress.

IsLoadedAsset(string)

Checks if the asset at the specified path is already loaded.

public static bool IsLoadedAsset(string assetPath)

Parameters

assetPath string

Asset path

Returns

bool

True if the asset is loaded, otherwise false.

IsLoadedAsset(AssetRef)

Is the asset for that assetRef loaded?

public static bool IsLoadedAsset(AssetRef assetRef)

Parameters

assetRef AssetRef

asset reference

Returns

bool

true if the asset has been loaded false otherwise

LoadAssetAsync<T>(string)

Asynchronously loads an asset at the specified path.

public static TAsyncOperation<AssetHandle<T>> LoadAssetAsync<T>(string assetPath) where T : Object

Parameters

assetPath string

Asset path

Returns

TAsyncOperation<AssetHandle<T>>

TAsyncOperation object containing the loaded asset handle.

Type Parameters

T

The type of asset to load (a class that inherits from UnityEngine.Object).

LoadAssetAsync<T>(AssetRef)

Load asset by asset reference

public static TAsyncOperation<AssetHandle<T>> LoadAssetAsync<T>(AssetRef assetRef) where T : Object

Parameters

assetRef AssetRef

asset reference

Returns

TAsyncOperation<AssetHandle<T>>

A handle to that asset

Type Parameters

T

asset type

LoadCatalogInfoAsync(string)

Asynchronously loads the catalog information of the specified catalog name.

public static TAsyncOperation<IAssetCatalogInfo> LoadCatalogInfoAsync(string catalogName)

Parameters

catalogName string

Catalog name

Returns

TAsyncOperation<IAssetCatalogInfo>

TAsyncOperation object containing the loaded catalog information (IAssetCatalogInfo).

LoadSceneAsync(string, LoadSceneMode)

Asynchronously loads a scene using the specified name or path and load scene mode.

public static TAsyncOperation LoadSceneAsync(string sceneNameOrPath, LoadSceneMode loadSceneMode = LoadSceneMode.Single)

Parameters

sceneNameOrPath string

Scene name or path

loadSceneMode LoadSceneMode

Scene load mode (default is LoadSceneMode.Single)

Returns

TAsyncOperation

TAsyncOperation object containing the scene load progress.

LoadSceneAsync(LoadSceneInfo)

Asynchronously loads a scene using LoadSceneInfo.

public static TAsyncOperation LoadSceneAsync(LoadSceneInfo loadSceneInfo)

Parameters

loadSceneInfo LoadSceneInfo

Scene load information object

Returns

TAsyncOperation

TAsyncOperation object containing the scene load progress.

LoadSceneAsync(SceneAssetRef, LoadSceneMode)

Load the scene with the scene asset reference

public static TAsyncOperation LoadSceneAsync(SceneAssetRef sceneAssetRef, LoadSceneMode loadSceneMode = LoadSceneMode.Single)

Parameters

sceneAssetRef SceneAssetRef

scene asset reference

loadSceneMode LoadSceneMode

load scene mode

Returns

TAsyncOperation

SetAssetCatalogComparer(IAssetCatalogComparer)

Sets the asset catalog comparer to determine which catalog (local or remote) has the higher version.

public static void SetAssetCatalogComparer(IAssetCatalogComparer assetCatalogComparer)

Parameters

assetCatalogComparer IAssetCatalogComparer

The comparer interface that will be used to compare the local and remote asset catalogs. It implements the logic to check if the remote catalog has a higher version than the local catalog.

SetRemoteUrl(string)

Sets the remote URL. The [BuildTarget] in the URL will automatically change according to the current build target.

public static void SetRemoteUrl(string remoteUrl)

Parameters

remoteUrl string

Remote URL to set.

SetTagComparer(ITagComparer)

Sets the tag comparison method to be used on asset bundles.

public static void SetTagComparer(ITagComparer tagComparer)

Parameters

tagComparer ITagComparer

Tag comparison object implementing the ITagComparer interface.

SetWebRequestBeforeSendCallback(WebRequestCallback)

Sets a pre-web request callback. Allows for custom processing before sending a web request.

public static void SetWebRequestBeforeSendCallback(WebRequestCallback callback)

Parameters

callback WebRequestCallback

Web request pre-processing callback.

SetWebRequestResultCallback(WebRequestCallback)

Sets a web request result callback. Allows for customizing the processing of the results after a web request.

public static void SetWebRequestResultCallback(WebRequestCallback callback)

Parameters

callback WebRequestCallback

Web request result handling callback.

UnloadAll()

Unloads all assets and asset bundles to free memory.

public static void UnloadAll()

UnloadAsset(string)

Decreases the reference count of the asset at the specified path, unloading it automatically if no longer used.

public static bool UnloadAsset(string assetPath)

Parameters

assetPath string

Asset path

Returns

bool

True if the asset is successfully unloaded, otherwise false.

UnloadAsset(AssetHandle)

Decreases the reference count of the specified asset handle, unloading it automatically if no longer used.

public static bool UnloadAsset(AssetHandle assetHandle)

Parameters

assetHandle AssetHandle

Asset handle

Returns

bool

True if the asset is successfully unloaded, otherwise false.

UnloadAsset(AssetRef)

Decreases the reference count of the asset reference. When an AssetBundle containing an Asset is no longer referenced, it is automatically released.

public static bool UnloadAsset(AssetRef assetRef)

Parameters

assetRef AssetRef

asset reference

Returns

bool

true if the asset is released false otherwise

UpdateCatalogAsync()

Updates the default catalog.

public static TAsyncOperation<bool> UpdateCatalogAsync()

Returns

TAsyncOperation<bool>

TAsyncOperation object that returns true if the update is successful, otherwise false.

UpdateCatalogAsync(string)

Updates the specified catalog.

public static TAsyncOperation<bool> UpdateCatalogAsync(string catalogName)

Parameters

catalogName string

Catalog name

Returns

TAsyncOperation<bool>

TAsyncOperation object that returns true if the update is successful, otherwise false.