Class TextureBase
Loads a KTX or Basis Universal texture from the StreamingAssets folder, a URL, or a buffer.
Inherited Members
Namespace: KtxUnity
Assembly: Ktx.dll
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
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>, bool, uint, uint, uint, bool)
Loads a KTX or Basis Universal texture from a buffer
Declaration
public Task<TextureResult> LoadFromBytes(NativeSlice<byte> data, bool linear = false, uint layer = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<byte> | data | Native buffer that holds the ktx/basis file |
bool | linear | Depicts if texture is sampled in linear or sRGB gamma color space. |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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, uint, uint, uint, bool)
Loads a KTX or Basis Universal texture from a buffer
Declaration
public Task<TextureResult> LoadFromBytes(NativeSlice<byte> data, GraphicsFormat targetFormat, uint layer = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
NativeSlice<byte> | data | Native buffer that holds the ktx/basis file |
GraphicsFormat | targetFormat | Desired texture format |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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, bool, uint, uint, uint, bool)
Loads a KTX or Basis Universal texture from the StreamingAssets folder see https://docs.unity3d.com/Manual/StreamingAssets.html
Declaration
public Task<TextureResult> LoadFromStreamingAssets(string filePath, bool linear = false, uint layer = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Path to the file, relative to StreamingAssets |
bool | linear | Depicts if texture is sampled in linear or sRGB gamma color space. |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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, uint, uint, uint, bool)
Loads a KTX or Basis Universal texture from the StreamingAssets folder see https://docs.unity3d.com/Manual/StreamingAssets.html
Declaration
public Task<TextureResult> LoadFromStreamingAssets(string filePath, GraphicsFormat targetFormat, uint layer = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
string | filePath | Path to the file, relative to StreamingAssets |
GraphicsFormat | targetFormat | Desired texture format |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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, bool, uint, uint, uint, bool)
Loads a KTX or Basis Universal texture from a URL
Declaration
public Task<TextureResult> LoadFromUrl(string url, bool linear = false, uint layer = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
string | url | URL to the ktx/basis file to load |
bool | linear | Depicts if texture is sampled in linear or sRGB gamma color space. |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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, uint, uint, uint, bool)
Loads a KTX or Basis Universal texture from a URL
Declaration
public Task<TextureResult> LoadFromUrl(string url, GraphicsFormat targetFormat, uint layer = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
string | url | URL to the ktx/basis file to load |
GraphicsFormat | targetFormat | Desired texture format |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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(bool, uint, uint, uint, bool)
Creates a 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 = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
bool | linear | Depicts if texture is sampled in linear or sRGB gamma color space. |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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
LoadTexture2D(GraphicsFormat, uint, uint, uint, bool)
Creates a 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 = 0, uint faceSlice = 0, uint mipLevel = 0, bool mipChain = true)
Parameters
Type | Name | Description |
---|---|---|
GraphicsFormat | targetFormat | Desired texture format |
uint | layer | Texture array layer to import |
uint | faceSlice | Cubemap face or 3D/volume texture slice to import. |
uint | 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. |
bool | 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>)
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 |
---|---|---|
NativeSlice<byte> | data | Input texture data |
Returns
Type | Description |
---|---|
ErrorCode | Success if loading was successful or an error specific code otherwise. |