docs.unity3d.com
    Show / Hide Table of Contents

    Class TextureBase

    Loads a KTX or Basis Universal texture from the StreamingAssets folder, a URL, or a buffer.

    Inheritance
    Object
    TextureBase
    BasisUniversalTexture
    KtxTexture
    Namespace: KtxUnity
    Syntax
    public abstract class TextureBase

    Methods

    Dispose()

    Releases all resources. Part of the low-level API that provides finer control over the loading process.

    Declaration
    public abstract void Dispose()
    See Also
    Open(NativeSlice<Byte>)
    LoadTexture2D(Boolean, UInt32, UInt32, UInt32, Boolean)
    LoadTexture2D(GraphicsFormat, UInt32, UInt32, UInt32, Boolean)
    Dispose()

    GetStreamingAssetsUrl(String)

    Converts a relative sub path within StreamingAssets and creates an absolute URI from it. Useful for loading via UnityWebRequests.

    Declaration
    public static string GetStreamingAssetsUrl(string subPath)
    Parameters
    Type Name Description
    String subPath

    Path, relative to StreamingAssets. Example: path/to/file.ktx

    Returns
    Type Description
    String

    Platform independent URI that can be loaded via UnityWebRequest

    LoadFromBytes(NativeSlice<Byte>, Boolean, UInt32, UInt32, UInt32, Boolean)

    Loads a KTX or Basis Universal texture from a buffer

    Declaration
    public async Task<TextureResult> LoadFromBytes(NativeSlice<byte> data, bool linear = false, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    Unity.Collections.NativeSlice<Byte> data

    Native buffer that holds the ktx/basis file

    Boolean linear

    Depicts if texture is sampled in linear or sRGB gamma color space.

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    LoadFromBytes(NativeSlice<Byte>, GraphicsFormat, UInt32, UInt32, UInt32, Boolean)

    Loads a KTX or Basis Universal texture from a buffer

    Declaration
    public async Task<TextureResult> LoadFromBytes(NativeSlice<byte> data, GraphicsFormat targetFormat, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    Unity.Collections.NativeSlice<Byte> data

    Native buffer that holds the ktx/basis file

    UnityEngine.Experimental.Rendering.GraphicsFormat targetFormat

    Desired texture format

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    LoadFromStreamingAssets(String, Boolean, UInt32, UInt32, UInt32, Boolean)

    Loads a KTX or Basis Universal texture from the StreamingAssets folder see https://docs.unity3d.com/Manual/StreamingAssets.html

    Declaration
    public async Task<TextureResult> LoadFromStreamingAssets(string filePath, bool linear = false, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    String filePath

    Path to the file, relative to StreamingAssets

    Boolean linear

    Depicts if texture is sampled in linear or sRGB gamma color space.

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    LoadFromStreamingAssets(String, GraphicsFormat, UInt32, UInt32, UInt32, Boolean)

    Loads a KTX or Basis Universal texture from the StreamingAssets folder see https://docs.unity3d.com/Manual/StreamingAssets.html

    Declaration
    public async Task<TextureResult> LoadFromStreamingAssets(string filePath, GraphicsFormat targetFormat, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    String filePath

    Path to the file, relative to StreamingAssets

    UnityEngine.Experimental.Rendering.GraphicsFormat targetFormat

    Desired texture format

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    LoadFromUrl(String, Boolean, UInt32, UInt32, UInt32, Boolean)

    Loads a KTX or Basis Universal texture from a URL

    Declaration
    public async Task<TextureResult> LoadFromUrl(string url, bool linear = false, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    String url

    URL to the ktx/basis file to load

    Boolean linear

    Depicts if texture is sampled in linear or sRGB gamma color space.

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    LoadFromUrl(String, GraphicsFormat, UInt32, UInt32, UInt32, Boolean)

    Loads a KTX or Basis Universal texture from a URL

    Declaration
    public async Task<TextureResult> LoadFromUrl(string url, GraphicsFormat targetFormat, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    String url

    URL to the ktx/basis file to load

    UnityEngine.Experimental.Rendering.GraphicsFormat targetFormat

    Desired texture format

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    LoadTexture2D(Boolean, UInt32, UInt32, UInt32, Boolean)

    Creates a UnityEngine.Texture2D from the previously opened texture. Transcodes or decodes the texture into a GPU compatible format (if required) and uploads it to GPU memory. Part of the low-level API that provides finer control over the loading process.

    Declaration
    public abstract Task<TextureResult> LoadTexture2D(bool linear = false, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    Boolean linear

    Depicts if texture is sampled in linear or sRGB gamma color space.

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    See Also
    Open(NativeSlice<Byte>)
    Dispose()

    LoadTexture2D(GraphicsFormat, UInt32, UInt32, UInt32, Boolean)

    Creates a UnityEngine.Texture2D from the previously opened texture. Transcodes or decodes the texture into a desired GPU compatible format (if required) and uploads it to GPU memory. Part of the low-level API that provides finer control over the loading process.

    Declaration
    public abstract Task<TextureResult> LoadTexture2D(GraphicsFormat targetFormat, uint layer = 0U, uint faceSlice = 0U, uint mipLevel = 0U, bool mipChain = true)
    Parameters
    Type Name Description
    UnityEngine.Experimental.Rendering.GraphicsFormat targetFormat

    Desired texture format

    UInt32 layer

    Texture array layer to import

    UInt32 faceSlice

    Cubemap face or 3D/volume texture slice to import.

    UInt32 mipLevel

    Lowest mipmap level to import (where 0 is the highest resolution). Lower mipmap levels (of higher resolution) are being discarded. Useful to limit texture resolution.

    Boolean mipChain

    If true, a mipmap chain (if present) is imported.

    Returns
    Type Description
    Task<TextureResult>

    A TextureResult that contains an ErrorCode, the resulting texture and its orientation.

    See Also
    Open(NativeSlice<Byte>)
    Dispose()

    Open(NativeSlice<Byte>)

    Loads a texture from memory. Part of the low-level API that provides finer control over the loading process.

    Declaration
    public abstract ErrorCode Open(NativeSlice<byte> data)
    Parameters
    Type Name Description
    Unity.Collections.NativeSlice<Byte> data

    Input texture data

    Returns
    Type Description
    ErrorCode

    Success if loading was successful or an error specific code otherwise.

    See Also
    LoadTexture2D(Boolean, UInt32, UInt32, UInt32, Boolean)
    LoadTexture2D(GraphicsFormat, UInt32, UInt32, UInt32, Boolean)
    Dispose()
    Back to top
    Terms of use
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023