TriLib
Search Results for

    Show / Hide Table of Contents

    Class TextureLoadingContext

    Contains data and state information for loading and processing a texture as part of TriLib's model import pipeline. This context holds both the source texture data (via TextureDataContext) and metadata (dimensions, component count, raw data) used to create a Unity Texture.

    Inheritance
    object
    TextureLoadingContext
    Implements
    IAssetLoaderContext
    IAwaitable
    Inherited Members
    object.GetType()
    object.MemberwiseClone()
    object.ToString()
    object.Equals(object)
    object.Equals(object, object)
    object.ReferenceEquals(object, object)
    object.GetHashCode()
    Namespace: TriLibCore
    Assembly: TriLibCore.dll
    Syntax
    public class TextureLoadingContext : IAssetLoaderContext, IAwaitable

    Constructors

    TextureLoadingContext(bool)

    Initializes a new instance of the TextureLoadingContext class.

    Declaration
    public TextureLoadingContext(bool createTextureData = true)
    Parameters
    Type Name Description
    bool createTextureData

    If true, a new TextureDataContext is created and assigned; otherwise, it remains uninitialized.

    Fields

    ByteData

    The texture data coming from StbImage.

    Declaration
    public byte[] ByteData
    Field Value
    Type Description
    byte[]

    CreationBitsPerChannel

    Gets or sets the number of bits per channel (e.g., 8 or 16) from the original image data.

    Declaration
    public int CreationBitsPerChannel
    Field Value
    Type Description
    int

    CreationBytesPerPixel

    (Obsolete) The number of bytes per pixel used during texture creation.

    Declaration
    [Obsolete("Please use CreationBitsPerChannel instead.")]
    public int CreationBytesPerPixel
    Field Value
    Type Description
    int

    MaterialMapperContext

    Gets or sets the MaterialMapperContext associated with this texture load. This context holds references to the virtual material and other material-specific properties.

    Declaration
    public MaterialMapperContext MaterialMapperContext
    Field Value
    Type Description
    MaterialMapperContext

    RawData

    Gets or sets the raw texture data as an array of bytes, which can be used to bypass the standard TriLib image loaders. When setting this field, ensure that the corresponding "Width", "Height", "Components", and "CreationBitsPerChannel" fields are also filled.

    Declaration
    public byte[] RawData
    Field Value
    Type Description
    byte[]

    TextureDataContext

    Gets or sets the TextureDataContext that stores the original texture data, including the source ITexture, dimensions, raw stream, and component count.

    Declaration
    public TextureDataContext TextureDataContext
    Field Value
    Type Description
    TextureDataContext

    TextureProcessed

    Indicates whether the texture has been processed.

    Declaration
    public bool TextureProcessed
    Field Value
    Type Description
    bool

    TextureType

    Gets or sets the type of texture being loaded (e.g., Diffuse, Normal, Specular).

    Declaration
    public TextureType TextureType
    Field Value
    Type Description
    TextureType

    Properties

    Completed

    Gets or sets a value indicating whether the texture loading process has completed.

    Declaration
    public bool Completed { get; set; }
    Property Value
    Type Description
    bool

    Components

    Gets or sets the number of color components in the texture (e.g., 3 for RGB or 4 for RGBA). If UseUnityNativeTextureLoader is false and EnforceAlphaChannelTextures is true, returns 4. Otherwise, it returns the value from Components.

    Declaration
    public int Components { get; set; }
    Property Value
    Type Description
    int

    Context

    Gets or sets the AssetLoaderContext containing the overall model loading data.

    Declaration
    public AssetLoaderContext Context { get; set; }
    Property Value
    Type Description
    AssetLoaderContext

    Data

    Gets the 8-bit raw texture data from the Unity texture when it has an RGBA8 format. If the texture is not 8 bits per channel, returns the default value.

    Declaration
    public NativeArray<byte> Data { get; }
    Property Value
    Type Description
    NativeArray<byte>

    Data16

    Gets the 16-bit raw texture data from the Unity texture when it has an RGBA16 format. If the texture is not 16 bits per channel, returns the default value.

    Declaration
    public NativeArray<ushort> Data16 { get; }
    Property Value
    Type Description
    NativeArray<ushort>

    Has16BPC

    Gets a value indicating whether the texture data is 16 bits per channel.

    Declaration
    public bool Has16BPC { get; }
    Property Value
    Type Description
    bool

    Has8BPC

    Gets a value indicating whether the texture data is 8 bits per channel.

    Declaration
    public bool Has8BPC { get; }
    Property Value
    Type Description
    bool

    HasAlpha

    Gets or sets a value indicating whether the source texture uses its alpha channel.

    Declaration
    public bool HasAlpha { get; set; }
    Property Value
    Type Description
    bool

    HasValidData

    Gets a value indicating whether either a texture stream or raw texture data is available.

    Declaration
    public bool HasValidData { get; }
    Property Value
    Type Description
    bool

    HasValidEmbeddedDataStream

    Gets a value indicating whether the texture embedded data stream is valid.

    Declaration
    public bool HasValidEmbeddedDataStream { get; }
    Property Value
    Type Description
    bool
    Remarks

    A stream is considered valid if it is not null, can be read, and has a length greater than zero.

    Height

    Gets or sets the height of the texture in pixels.

    Declaration
    public int Height { get; set; }
    Property Value
    Type Description
    int

    OriginalUnityTexture

    Gets or sets the original Unity texture created from the loaded texture data.

    Declaration
    public Texture OriginalUnityTexture { get; set; }
    Property Value
    Type Description
    Texture

    Stream

    Gets or sets the source stream for the texture data, stored in the underlying TextureDataContext.

    Declaration
    public Stream Stream { get; set; }
    Property Value
    Type Description
    Stream

    Texture

    Gets or sets the TriLib ITexture reference stored in the TextureDataContext.

    Declaration
    public ITexture Texture { get; set; }
    Property Value
    Type Description
    ITexture

    TextureCreated

    Gets or sets a value indicating whether the Unity texture has been created.

    Declaration
    public bool TextureCreated { get; set; }
    Property Value
    Type Description
    bool

    TextureLoaded

    Gets or sets a value indicating whether the Unity texture has been successfully loaded.

    Declaration
    public bool TextureLoaded { get; set; }
    Property Value
    Type Description
    bool

    UnityTexture

    Gets or sets the Unity texture instance that will eventually be created from the loaded data.

    Declaration
    public Texture UnityTexture { get; set; }
    Property Value
    Type Description
    Texture

    Width

    Gets or sets the width of the texture in pixels.

    Declaration
    public int Width { get; set; }
    Property Value
    Type Description
    int

    Implements

    IAssetLoaderContext
    IAwaitable

    Extension Methods

    IObjectExtensions.TryToDispose<T>(object)
    In this article
    Back to top Generated by DocFX