Search Results for

    Show / Hide Table of Contents

    Class TextureBase

    Base class for Texture, SpriteAtlas, IESProfile and other assets that can contain texture data.

    Inheritance
    System.Object
    Object
    Asset
    BinaryAsset
    TextureBase
    CubeTexture
    IESProfile
    SpriteAtlas
    Texture
    Inherited Members
    BinaryAsset.Reimport()
    BinaryAsset.ImportPath
    Asset.Reload()
    Asset.WaitForLoaded(Double)
    Asset.GetReferences()
    Asset.Save(String)
    Asset.ToString()
    Asset.ReferencesCount
    Asset.Path
    Asset.IsLoaded
    Asset.LastLoadFailed
    Asset.IsVirtual
    Asset.ShouldDeleteFileOnUnload
    Asset.MemoryUsage
    Object.__unmanagedPtr
    Object.__internalId
    Object.Finalize()
    Object.As<T>()
    Object.NewValue(Type)
    Object.New(String)
    Object.Find<T>(Guid, Boolean)
    Object.Find(Guid, Type, Boolean)
    Object.TryFind<T>(Guid)
    Object.TryFind(Guid, Type)
    Object.Destroy(Object, Single)
    Object.DestroyNow(Object)
    Object.Destroy<T>(T, Single)
    Object.Equals(Object)
    Object.GetUnmanagedPtr(Object)
    Object.GetUnmanagedInterface(Object, Type)
    Object.FromUnmanagedPtr(IntPtr)
    Object.MapObjectID(Guid)
    Object.RemapObjectID(Guid)
    Object.GetHashCode()
    Object.ID
    Object.TypeName
    Namespace: FlaxEngine
    Assembly: FlaxEngine.CSharp.dll
    Syntax
    [Unmanaged]
    public abstract class TextureBase : BinaryAsset

    Constructors

    TextureBase()

    Initializes a new instance of the TextureBase.

    Declaration
    protected TextureBase()

    Fields

    MaxArraySize

    The maximum array size for the texture resources (supported by engine, the target platform can be lower capabilities).

    Declaration
    public const int MaxArraySize = 512
    Field Value
    System.Int32

    MaxMipLevels

    The maximum amount of the mip levels for the texture resources (supported by engine, the target platform can be lower capabilities).

    Declaration
    public const int MaxMipLevels = 14
    Field Value
    System.Int32

    MaxTextureSize

    The maximum size for the texture resources (supported by engine, the target platform can be lower capabilities).

    Declaration
    public const int MaxTextureSize = 8192
    Field Value
    System.Int32

    Properties

    ArraySize

    Gets the total array size of the texture.

    Declaration
    [Unmanaged]
    public int ArraySize { get; }
    Property Value
    System.Int32

    CurrentMemoryUsage

    Gets the amount of the memory used by this resource. Exact value may differ due to memory alignment and resource allocation policy.

    Declaration
    [Unmanaged]
    public ulong CurrentMemoryUsage { get; }
    Property Value
    System.UInt64

    Format

    Gets the texture data format.

    Declaration
    [Unmanaged]
    public PixelFormat Format { get; }
    Property Value
    PixelFormat

    HasStreamingError

    Returns true if texture streaming failed (eg. pixel format is unsupported or texture data cannot be uploaded to GPU due to memory limit).

    Declaration
    [Unmanaged]
    public bool HasStreamingError { get; }
    Property Value
    System.Boolean

    Height

    Gets the total height of the texture. Actual resident size may be different due to dynamic content streaming. Returns 0 if texture is not loaded.

    Declaration
    [Unmanaged]
    public int Height { get; }
    Property Value
    System.Int32

    MipLevels

    Gets the total mip levels count of the texture. Actual resident mipmaps count may be different due to dynamic content streaming.

    Declaration
    [Unmanaged]
    public int MipLevels { get; }
    Property Value
    System.Int32

    ResidentMipLevels

    Gets the current mip levels count of the texture that are on GPU ready to use.

    Declaration
    [Unmanaged]
    public int ResidentMipLevels { get; }
    Property Value
    System.Int32

    Size

    Gets the total size of the texture. Actual resident size may be different due to dynamic content streaming. Returns Float2.Zero if texture is not loaded.

    Declaration
    [Unmanaged]
    public Float2 Size { get; }
    Property Value
    Float2

    Texture

    Gets GPU texture object allocated by the asset.

    Declaration
    [Unmanaged]
    public GPUTexture Texture { get; }
    Property Value
    GPUTexture

    TextureGroup

    Gets or sets the index of the texture group used by this texture.

    Declaration
    [Unmanaged]
    public int TextureGroup { get; set; }
    Property Value
    System.Int32

    TotalMemoryUsage

    Gets the total memory usage that texture may have in use (if loaded to the maximum quality). Exact value may differ due to memory alignment and resource allocation policy.

    Declaration
    [Unmanaged]
    public ulong TotalMemoryUsage { get; }
    Property Value
    System.UInt64

    Width

    Gets the total width of the texture. Actual resident size may be different due to dynamic content streaming. Returns 0 if texture is not loaded.

    Declaration
    [Unmanaged]
    public int Width { get; }
    Property Value
    System.Int32

    Methods

    GetMipData(Int32, out Int32, out Int32)

    Gets the mip data.

    Declaration
    [Unmanaged]
    public byte[] GetMipData(int mipIndex, out int rowPitch, out int slicePitch)
    Parameters
    System.Int32 mipIndex

    The mip index (zero-based).

    System.Int32 rowPitch

    The data row pitch (in bytes).

    System.Int32 slicePitch

    The data slice pitch (in bytes).

    Returns
    System.Byte[]

    The mip-map data or empty if failed to get it.

    GetPixels(out Color[], Int32, Int32)

    Gets the texture pixels as Color array.

    Declaration
    [Unmanaged]
    public bool GetPixels(out Color[] pixels, int mipIndex = 0, int arrayIndex = 0)
    Parameters
    Color[] pixels

    The result texture pixels array.

    System.Int32 mipIndex

    The mip index (zero-based).

    System.Int32 arrayIndex

    The array or depth slice index (zero-based).

    Returns
    System.Boolean

    True if failed, otherwise false.

    Remarks

    Supported only for 'basic' texture formats (uncompressed, single plane).

    GetPixels(out Color32[], Int32, Int32)

    Gets the texture pixels as Color32 array.

    Declaration
    [Unmanaged]
    public bool GetPixels(out Color32[] pixels, int mipIndex = 0, int arrayIndex = 0)
    Parameters
    Color32[] pixels

    The result texture pixels array.

    System.Int32 mipIndex

    The mip index (zero-based).

    System.Int32 arrayIndex

    The array or depth slice index (zero-based).

    Returns
    System.Boolean

    True if failed, otherwise false.

    Remarks

    Supported only for 'basic' texture formats (uncompressed, single plane).

    Init(ref TextureBase.InitData)

    Initializes the texture storage container with the given data. Valid only for virtual assets. Can be used in both Editor and at runtime in a build game. It does not perform any data streaming or uploading to the GPU. Only the texture resource is being initialized and the data is copied to be streamed later.

    Declaration
    public void Init(ref TextureBase.InitData initData)
    Parameters
    TextureBase.InitData initData

    The texture init data.

    Remarks

    Can be used only for virtual assets (see IsVirtual and CreateVirtualAsset<T>()).

    SetPixels(Color[], Int32, Int32, Boolean)

    Sets the texture pixels as Color array (asset must be virtual and already initialized).

    Declaration
    [Unmanaged]
    public bool SetPixels(Color[] pixels, int mipIndex = 0, int arrayIndex = 0, bool generateMips = false)
    Parameters
    Color[] pixels

    The texture pixels array.

    System.Int32 mipIndex

    The mip index (zero-based).

    System.Int32 arrayIndex

    The array or depth slice index (zero-based).

    System.Boolean generateMips

    Enables automatic mip-maps generation (fast point filter) based on the current mip (will generate lower mips).

    Returns
    System.Boolean

    True if failed, otherwise false.

    Remarks

    Supported only for 'basic' texture formats (uncompressed, single plane).

    SetPixels(Color32[], Int32, Int32, Boolean)

    Sets the texture pixels as Color32 array (asset must be virtual and already initialized).

    Declaration
    [Unmanaged]
    public bool SetPixels(Color32[] pixels, int mipIndex = 0, int arrayIndex = 0, bool generateMips = false)
    Parameters
    Color32[] pixels

    The texture pixels array.

    System.Int32 mipIndex

    The mip index (zero-based).

    System.Int32 arrayIndex

    The array or depth slice index (zero-based).

    System.Boolean generateMips

    Enables automatic mip-maps generation (fast point filter) based on the current mip (will generate lower mips).

    Returns
    System.Boolean

    True if failed, otherwise false.

    Remarks

    Supported only for 'basic' texture formats (uncompressed, single plane).

    Extension Methods

    Extensions.ReflectiveCompare<T>(T, T)
    Extensions.RawClone<T>(T)

    See Also

    BinaryAsset
    In This Article
    Back to top Copyright © 2012-2024 Wojciech Figat