Search Results for

    Show / Hide Table of Contents

    Class ExternalFileLoaderBase<T>

    Abstract base class for loading external files of type T. Can be extended to support different file types by implementing the abstract methods.

    Inheritance
    System.Object
    ExternalFileLoaderBase<T>
    ExternalAudioLoader
    ExternalTextureLoader
    Inherited Members
    System.Object.ToString()
    System.Object.Equals(System.Object)
    System.Object.Equals(System.Object, System.Object)
    System.Object.ReferenceEquals(System.Object, System.Object)
    System.Object.GetHashCode()
    System.Object.GetType()
    System.Object.MemberwiseClone()
    Namespace: MGeLabs.Utils.Data
    Assembly: cs.temp.dll.dll
    Syntax
    public abstract class ExternalFileLoaderBase<T>
    Type Parameters
    Name Description
    T

    The type of data to be returned (AudioClip, VideoClip, ...).

    Properties

    SupportedExtensions

    Gets the list of supported file extensions for this loader.

    Declaration
    protected abstract List<string> SupportedExtensions { get; }
    Property Value
    Type Description
    List<System.String>

    Methods

    FindFilesInDirectory(String, EStorageLocation)

    Finds files in the specified directory that match the supported extensions.

    Declaration
    protected virtual List<FileHandle> FindFilesInDirectory(string relativePath, EStorageLocation location = EStorageLocation.DataPath)
    Parameters
    Type Name Description
    System.String relativePath

    The relative path to the directory.

    EStorageLocation location

    The storage location of the directory (default is DataPath).

    Returns
    Type Description
    List<FileHandle>

    A list of file handles for the matching files.

    LoadFromDirectory(String, EStorageLocation, Action<IReadOnlyList<T>>, Action<IReadOnlyList<T>>, Action<FileHandle, Int32>, Int32)

    Loads files from a specified directory asynchronously in batches.

    Declaration
    public virtual IEnumerator LoadFromDirectory(string relativePath, EStorageLocation location = EStorageLocation.DataPath, Action<IReadOnlyList<T>> onLoadingFinished = null, Action<IReadOnlyList<T>> onBatchFinished = null, Action<FileHandle, int> onError = null, int loadBatchSize = 10)
    Parameters
    Type Name Description
    System.String relativePath

    The relative path to the directory containing the files.

    EStorageLocation location

    The storage location of the directory (default is DataPath).

    Action<IReadOnlyList<T>> onLoadingFinished

    Callback invoked when all files have been loaded successfully; receives the list of loaded items.

    Action<IReadOnlyList<T>> onBatchFinished

    Callback invoked after each batch of files is loaded; receives the full list of currently loaded items.

    Action<FileHandle, System.Int32> onError

    Callback invoked for each file that fails to load; receives the file handle and an integer error code.

    System.Int32 loadBatchSize

    The number of files to load per batch (default is 10).

    Returns
    Type Description
    IEnumerator

    An enumerator for the coroutine.

    LoadSingleFileRoutine(FileHandle, Action<T>, Action<FileHandle, Int32>)

    Loads a single file asynchronously. Must be implemented by derived classes to handle the loading/parsing of the specific file type.

    Declaration
    protected abstract IEnumerator LoadSingleFileRoutine(FileHandle handle, Action<T> onLoadingFinished, Action<FileHandle, int> onError = null)
    Parameters
    Type Name Description
    FileHandle handle

    The file handle representing the file to load.

    Action<T> onLoadingFinished

    Callback invoked with the loaded item upon success.

    Action<FileHandle, System.Int32> onError

    Callback invoked if the file fails to load.

    Returns
    Type Description
    IEnumerator

    An enumerator for the coroutine.

    In This Article
    Back to top MGeUtils Documentation