Class MultipleAssetLoaderZip
Provides methods to load every recognized model file within a .zip archive,
leveraging TriLib’s AssetLoader under the hood. Unlike AssetLoaderZip
,
this class attempts to load multiple models from the same .zip file rather than just the first.
Inherited Members
Namespace: TriLibCore
Assembly: Assembly-CSharp.dll
Syntax
public static class MultipleAssetLoaderZip
Methods
LoadAllModelsFromZipFile(string, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, object, string, bool, Action<AssetLoaderContext>)
Loads all valid 3D models from a local .zip file asynchronously if the platform allows threading. Each recognized file extension within the .zip is processed individually, creating separate TriLibCore.AssetLoaderContext instances for each model.
Declaration
public static void LoadAllModelsFromZipFile(string path, Action<AssetLoaderContext> onLoad, Action<AssetLoaderContext> onMaterialsLoad, Action<AssetLoaderContext, float> onProgress, Action<IContextualizedError> onError = null, GameObject wrapperGameObject = null, AssetLoaderOptions assetLoaderOptions = null, object customContextData = null, string fileExtension = null, bool haltTask = false, Action<AssetLoaderContext> onPreLoad = null)
Parameters
Type | Name | Description |
---|---|---|
string | path | The absolute or relative file path to the .zip archive. If the file doesn’t exist, an Exception is thrown. |
Action<AssetLoaderContext> | onLoad | Callback invoked on the main Unity thread once any model’s core data is loaded (but before materials fully load). |
Action<AssetLoaderContext> | onMaterialsLoad | Callback invoked after each model’s materials (textures, shaders, etc.) have been loaded. This occurs on the main Unity thread. |
Action<AssetLoaderContext, float> | onProgress | Callback invoked whenever any model’s loading progress is updated (a float from 0 to 1). This can be called multiple times per model load. |
Action<IContextualizedError> | onError | Callback invoked if any error occurs while extracting or loading models from the .zip.
Optionally, pass |
GameObject | wrapperGameObject | An optional parent UnityEngine.GameObject under which loaded models will be placed.
If |
AssetLoaderOptions | assetLoaderOptions | The TriLibCore.AssetLoaderOptions that govern texture loading, material creation,
animations, and other aspects of model import. If |
object | customContextData | An optional data object inserted into each TriLibCore.AssetLoaderContext for custom reference. |
string | fileExtension | A specific file extension (e.g., |
bool | haltTask | If |
Action<AssetLoaderContext> | onPreLoad | A background-thread callback invoked before Unity objects are generated, suitable for advanced tasks such as caching or data pre-processing. |
Exceptions
Type | Condition |
---|---|
Exception | Thrown if the |
LoadAllModelsFromZipStream(Stream, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, object, string, bool, Action<AssetLoaderContext>)
Loads all valid 3D models from the specified stream
(a .zip file stream)
asynchronously if the platform allows threading. Each recognized file extension is
processed individually, generating a separate TriLibCore.AssetLoaderContext.
Declaration
public static void LoadAllModelsFromZipStream(Stream stream, Action<AssetLoaderContext> onLoad, Action<AssetLoaderContext> onMaterialsLoad, Action<AssetLoaderContext, float> onProgress, Action<IContextualizedError> onError = null, GameObject wrapperGameObject = null, AssetLoaderOptions assetLoaderOptions = null, object customContextData = null, string fileExtension = null, bool haltTask = false, Action<AssetLoaderContext> onPreLoad = null)
Parameters
Type | Name | Description |
---|---|---|
Stream | stream | A Stream pointing to the .zip data. The stream is scanned for valid model files (based on known TriLib extensions). |
Action<AssetLoaderContext> | onLoad | Callback invoked on the main Unity thread once any model’s core data is loaded (but before materials have fully loaded). |
Action<AssetLoaderContext> | onMaterialsLoad | Callback invoked on the main Unity thread after each model’s materials (textures, shaders, etc.) have finished loading. |
Action<AssetLoaderContext, float> | onProgress | Callback invoked whenever any model’s loading progress is updated (0–1). Includes both data and materials loading stages. |
Action<IContextualizedError> | onError | Callback invoked on the main Unity thread if any error occurs while extracting or loading a model.
This is optional and can be |
GameObject | wrapperGameObject | An optional parent UnityEngine.GameObject to hold the loaded model hierarchies.
If |
AssetLoaderOptions | assetLoaderOptions | The TriLibCore.AssetLoaderOptions controlling how models, textures, and other data
are processed. If |
object | customContextData | A custom object or data structure used to store additional information in each TriLibCore.AssetLoaderContext. This can be retrieved later via the loading pipeline. |
string | fileExtension | If specified, only files in the .zip that match this extension (e.g., |
bool | haltTask | If |
Action<AssetLoaderContext> | onPreLoad | A callback invoked on a background thread before Unity objects are created (in supported platforms), useful for advanced setup or logging tasks in parallel. |
Remarks
If multiple models are found, each model is loaded in turn, potentially creating
multiple UnityEngine.GameObject hierarchies under wrapperGameObject
.