docs.unity3d.com
Search Results for

    Show / Hide Table of Contents

    Interface ITextureImageLoader

    Creates a Texture2D from raw, usually compressed image data.

    Namespace: GLTFast
    Assembly: glTFast.dll
    Syntax
    public interface ITextureImageLoader

    Methods

    IsAbleToLoad(TextureBase, out int)

    Determines if this loader can load the given texture, and if so, returns the corresponding image index. The typical use-case is a glTF texture extension that adds support for a new image format, e.g. EXT_texture_webp. The loader may also update the image index to point to a different image, e.g. if the extension adds support for a new image format that is stored in a different image than the one referenced by the texture.

    Declaration
    bool IsAbleToLoad(TextureBase texture, out int imageIndex)
    Parameters
    Type Name Description
    TextureBase texture

    glTF texture.

    int imageIndex

    Corresponding, potentially updated glTF image index.

    Returns
    Type Description
    bool

    True if the texture image loader supports loading that texture, false otherwise.

    IsAbleToLoad(ReadOnlySpan<byte>)

    Implement this to support content-based image format detection. This is optional, but fixes loading of glTF images where the type could not be derived from the mime type or file extension.

    Declaration
    bool IsAbleToLoad(ReadOnlySpan<byte> data)
    Parameters
    Type Name Description
    ReadOnlySpan<byte> data

    Image data.

    Returns
    Type Description
    bool

    True if the image loader supports loading that data, false otherwise.

    LoadImage(ReadOnly, bool, bool, bool, CancellationToken)

    Creates an image from the input data.

    Declaration
    Task<ImageResult> LoadImage(NativeArray<byte>.ReadOnly data, bool linear, bool readable, bool generateMipMaps, CancellationToken cancellationToken)
    Parameters
    Type Name Description
    NativeArray<byte>.ReadOnly data

    Raw, compressed image data.

    bool linear

    If true, the texture being created is in linear space. If false, it is in sRGB space.

    bool readable

    If true, the resulting texture should remain readable (UnityEngine.Texture2D.isReadable).

    bool generateMipMaps

    If true, mipmap levels should get generated.

    CancellationToken cancellationToken

    Token to submit cancellation requests. The default value is None.

    Returns
    Type Description
    Task<ImageResult>

    An image texture result

    In This Article
    Back to top
    Copyright © 2026 Unity Technologies — Trademarks and terms of use
    • Legal
    • Privacy Policy
    • Cookie Policy
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)