Class AssetDownloaderBehaviour
Provides coroutines for asynchronously downloading model data from a remote source, then passing that data to TriLib’s AssetLoader or AssetLoaderZip for actual model loading. This component is spawned at runtime by LoadModelFromUri(UnityWebRequest, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, object, string, bool?, bool) and automatically destroyed once the download and loading processes finish.
Inherited Members
Namespace: TriLibCore
Assembly: Assembly-CSharp.dll
Syntax
public class AssetDownloaderBehaviour : MonoBehaviour
Methods
DownloadAsset(UnityWebRequest, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, GameObject, Action<IContextualizedError>, AssetLoaderOptions, object, string, bool?)
Downloads the model data via the given unityWebRequest
, then
hands off the data to the appropriate loading method (LoadModelFromStream(Stream, string, string, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, object, bool, Action<AssetLoaderContext>, bool)
or LoadModelFromZipStream(Stream, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, object, string, bool, string, Action<AssetLoaderContext>)) based on file extension or
content type. Once completed, this UnityEngine.GameObject is destroyed.
Declaration
public IEnumerator DownloadAsset(UnityWebRequest unityWebRequest, Action<AssetLoaderContext> onLoad, Action<AssetLoaderContext> onMaterialsLoad, Action<AssetLoaderContext, float> onProgress, GameObject wrapperGameObject, Action<IContextualizedError> onError, AssetLoaderOptions assetLoaderOptions, object customContextData, string fileExtension, bool? isZipFile = null)
Parameters
Type | Name | Description |
---|---|---|
UnityWebRequest | unityWebRequest | The UnityEngine.Networking.UnityWebRequest object prepared for downloading the model data. |
Action<AssetLoaderContext> | onLoad | A callback invoked on the main thread once the core model data has been processed (but before materials are fully loaded). |
Action<AssetLoaderContext> | onMaterialsLoad | A callback invoked on the main thread once the model’s materials (textures, shaders, etc.) have finished loading. |
Action<AssetLoaderContext, float> | onProgress | A callback invoked throughout the download and loading process, indicating progress
with a |
GameObject | wrapperGameObject | An optional parent UnityEngine.GameObject under which the loaded model's
UnityEngine.GameObject is placed. Can be |
Action<IContextualizedError> | onError | A callback invoked if any error occurs during download or loading. Called on the main thread. |
AssetLoaderOptions | assetLoaderOptions | The TriLibCore.AssetLoaderOptions controlling how the model is loaded (e.g., materials, textures, animations). |
object | customContextData | Optional custom data that can be stored in the TriLibCore.AssetLoaderContext for reference in the loading pipeline. |
string | fileExtension | The file extension for the model (e.g., |
bool? | isZipFile | A boolean (or |
Returns
Type | Description |
---|---|
IEnumerator | An IEnumerator that can be yielded in a Unity coroutine, controlling the download process. Once the download completes and loading is triggered, this object destroys itself via Object.Destroy. |