Class IOAssetLoader
Provides functionality for selecting and loading 3D models from file streams (including archives) and applying them to the Unity scene using TriLib’s AssetLoader pipeline. This class manages callbacks for model loading, progress reporting, and error handling, and it can optionally destroy itself after the loading process completes.
Inherited Members
Namespace: TriLibCore
Assembly: Assembly-CSharp.dll
Syntax
public class IOAssetLoader : MonoBehaviour
Fields
AssetLoaderOptions
Contains settings that control TriLib’s import behavior, such as material/texture handling,
colliders, animation type, etc. If null
, default options are generated.
Declaration
protected AssetLoaderOptions AssetLoaderOptions
Field Value
Type | Description |
---|---|
AssetLoaderOptions |
AutoDestroy
Indicates whether this loader component should self-destruct (destroy its UnityEngine.GameObject) once model loading completes or fails.
Declaration
protected bool AutoDestroy
Field Value
Type | Description |
---|---|
bool |
HaltTask
If true
, tasks for model loading are created but not started immediately,
allowing the caller to chain or manage them manually.
Declaration
protected bool HaltTask
Field Value
Type | Description |
---|---|
bool |
OnBeginLoad
A callback invoked once file loading begins, passing a bool indicating whether valid files are actually being loaded.
Declaration
protected Action<bool> OnBeginLoad
Field Value
Type | Description |
---|---|
Action<bool> |
OnError
A callback invoked on the main Unity thread if any error occurs during file selection or loading. Carries an TriLibCore.IContextualizedError with error details.
Declaration
protected Action<IContextualizedError> OnError
Field Value
Type | Description |
---|---|
Action<IContextualizedError> |
OnLoad
A callback invoked on the main Unity thread after the model’s core data has been loaded (but potentially before all materials and textures have finished).
Declaration
protected Action<AssetLoaderContext> OnLoad
Field Value
Type | Description |
---|---|
Action<AssetLoaderContext> |
OnMaterialsLoad
A callback invoked on the main Unity thread after all materials, textures, and other resources have finished loading for the model.
Declaration
protected Action<AssetLoaderContext> OnMaterialsLoad
Field Value
Type | Description |
---|---|
Action<AssetLoaderContext> |
OnProgress
A callback triggered whenever the loading progress updates (from 0 to 1). Receives both the TriLibCore.AssetLoaderContext and a float progress value.
Declaration
protected Action<AssetLoaderContext, float> OnProgress
Field Value
Type | Description |
---|---|
Action<AssetLoaderContext, float> |
WrapperGameObject
An optional parent UnityEngine.GameObject under which the loaded model hierarchy
will be placed. If null
, the model is created at the scene’s root level.
Declaration
protected GameObject WrapperGameObject
Field Value
Type | Description |
---|---|
GameObject |
Methods
DestroyMe()
Safely destroys the UnityEngine.GameObject hosting this loader component.
This is called if AutoDestroy is true
or upon certain
error conditions.
Declaration
protected void DestroyMe()
GetExtensions()
Constructs a list of ExtensionFilter objects representing valid 3D model
file extensions recognized by TriLib, plus "zip"
support. An “All Files” filter
is also appended for user convenience.
Declaration
protected static ExtensionFilter[] GetExtensions()
Returns
Type | Description |
---|---|
ExtensionFilter[] | An array of ExtensionFilter used by file-picker dialogs to filter selectable files. |
OnItemsWithStreamSelected(IList<ItemWithStream>)
Called once the user has selected or provided streams to load. If valid streams are present, this method triggers file loading via TriLibCore.IOAssetLoader.HandleFileLoading(). Otherwise, it performs cleanup if AutoDestroy is enabled.
Declaration
protected void OnItemsWithStreamSelected(IList<ItemWithStream> itemsWithStream)
Parameters
Type | Name | Description |
---|---|---|
IList<ItemWithStream> | itemsWithStream | A list of file data items (each containing a Stream) for model loading.
May be |