Class AssetLoaderFilePicker
Extends IOAssetLoader to handle model file or directory selection using a platform-specific file picker. Once a user selects one or more files/folders, TriLib's loading pipeline is triggered to import the models (including materials, textures, etc.).
Inherited Members
Namespace: TriLibCore
Assembly: Assembly-CSharp.dll
Syntax
public class AssetLoaderFilePicker : IOAssetLoader
Methods
Create()
Creates a new AssetLoaderFilePicker singleton instance attached to a UnityEngine.GameObject in the current scene. By default, AutoDestroy is enabled, causing the component to self-destruct once loading completes or fails.
Declaration
public static AssetLoaderFilePicker Create()
Returns
Type | Description |
---|---|
AssetLoaderFilePicker | A reference to the newly instantiated AssetLoaderFilePicker. |
LoadModelFromDirectoryPickerAsync(string, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<bool>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, bool)
Opens an OS-native folder selection dialog asynchronously, allowing the user to pick one or more directories containing model files. TriLib then scans and loads any recognized models in the background, invoking the provided callbacks for load completion, material loading, progress, or errors.
Declaration
public void LoadModelFromDirectoryPickerAsync(string title, Action<AssetLoaderContext> onLoad, Action<AssetLoaderContext> onMaterialsLoad, Action<AssetLoaderContext, float> onProgress, Action<bool> onBeginLoad, Action<IContextualizedError> onError, GameObject wrapperGameObject, AssetLoaderOptions assetLoaderOptions, bool haltTask = false)
Parameters
Type | Name | Description |
---|---|---|
string | title | The title displayed in the folder dialog window. |
Action<AssetLoaderContext> | onLoad | A callback invoked on the main thread once each model is loaded (before its materials may be fully processed). |
Action<AssetLoaderContext> | onMaterialsLoad | A callback invoked on the main thread after each model’s materials (textures, shaders, etc.) are fully loaded. |
Action<AssetLoaderContext, float> | onProgress | A callback reporting the model loading progress (range 0–1). |
Action<bool> | onBeginLoad | A callback invoked when loading starts, with a |
Action<IContextualizedError> | onError | A callback invoked if an error occurs during directory selection or loading, supplying an TriLibCore.IContextualizedError for logging or UI feedback. |
GameObject | wrapperGameObject | An optional parent UnityEngine.GameObject under which loaded models will be placed.
If |
AssetLoaderOptions | assetLoaderOptions | A set of TriLibCore.AssetLoaderOptions that control the import process. If |
bool | haltTask | If |
Remarks
Similar to LoadModelFromFilePickerAsync(string, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<bool>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, bool) but uses a folder selection UI and attempts to load any recognized 3D files found in the chosen directories.
LoadModelFromFilePickerAsync(string, Action<AssetLoaderContext>, Action<AssetLoaderContext>, Action<AssetLoaderContext, float>, Action<bool>, Action<IContextualizedError>, GameObject, AssetLoaderOptions, bool)
Opens an OS-native file selection dialog asynchronously, allowing the user to pick one or more model files. TriLib then loads the selected model(s) in the background, invoking the provided callbacks at each stage (e.g., initial load, material load, progress, error).
Declaration
public void LoadModelFromFilePickerAsync(string title, Action<AssetLoaderContext> onLoad, Action<AssetLoaderContext> onMaterialsLoad, Action<AssetLoaderContext, float> onProgress, Action<bool> onBeginLoad, Action<IContextualizedError> onError, GameObject wrapperGameObject, AssetLoaderOptions assetLoaderOptions, bool haltTask = false)
Parameters
Type | Name | Description |
---|---|---|
string | title | The title displayed in the file dialog window. |
Action<AssetLoaderContext> | onLoad | A callback invoked on the main thread once the model is loaded (but possibly before all materials have been processed). |
Action<AssetLoaderContext> | onMaterialsLoad | A callback invoked on the main thread after the model’s materials (textures, shaders, etc.) are fully loaded. |
Action<AssetLoaderContext, float> | onProgress | A callback that receives updates on the model loading progress (0 to 1). |
Action<bool> | onBeginLoad | A callback invoked when the loading process begins, passing a |
Action<IContextualizedError> | onError | A callback invoked if any error occurs during the file selection or loading process, providing an TriLibCore.IContextualizedError for debugging or user messaging. |
GameObject | wrapperGameObject | An optional parent UnityEngine.GameObject under which the loaded model(s)
will be placed. If |
AssetLoaderOptions | assetLoaderOptions | A set of TriLibCore.AssetLoaderOptions that govern loading behavior
(e.g., whether to import lights, animations, colliders, etc.). If |
bool | haltTask | If |
Remarks
This method calls OnItemsWithStreamSelected once the user finishes selecting files, which triggers the actual load process through TriLib’s pipeline.