TriLib
Search Results for

    Show / Hide Table of Contents

    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.

    Inheritance
    object
    MultipleAssetLoaderZip
    Inherited Members
    object.Equals(object)
    object.Equals(object, object)
    object.GetHashCode()
    object.GetType()
    object.MemberwiseClone()
    object.ReferenceEquals(object, object)
    object.ToString()
    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 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 null if no error handling is needed.

    GameObject wrapperGameObject

    An optional parent UnityEngine.GameObject under which loaded models will be placed. If null, each model is created at the root scene level.

    AssetLoaderOptions assetLoaderOptions

    The AssetLoaderOptions that govern texture loading, material creation, animations, and other aspects of model import. If null, a default configuration is used.

    object customContextData

    An optional data object inserted into each AssetLoaderContext for custom reference.

    string fileExtension

    A specific file extension (e.g., ".gltf") to limit which models to load from the .zip. If null, all recognized TriLib model extensions are loaded.

    bool haltTask

    If true, creates but does not begin loading tasks, letting you manage or queue them as needed.

    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 path does not point to a valid file.

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

    GameObject wrapperGameObject

    An optional parent UnityEngine.GameObject to hold the loaded model hierarchies. If null, each model is created at the root of the scene.

    AssetLoaderOptions assetLoaderOptions

    The AssetLoaderOptions controlling how models, textures, and other data are processed. If null, default settings are created automatically.

    object customContextData

    A custom object or data structure used to store additional information in each 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., ".fbx") are loaded. If null, any valid TriLib file extension is accepted.

    bool haltTask

    If true, creates the loading tasks but does not start them immediately, allowing you to chain or queue multiple loads manually.

    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.

    In this article
    Back to top Generated by DocFX