Class IOExtensions
Inherited Members
Namespace: Glitch9.IO
Assembly: Glitch9.IO.dll
Syntax
public static class IOExtensions
Methods
| Edit this page View SourceToAudioClip(IAudioAsset)
Converts an IAudioAsset to a Unity AudioClip synchronously.
Declaration
public static AudioClip ToAudioClip(this IAudioAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IAudioAsset | d | The audio asset to convert. |
Returns
| Type | Description |
|---|---|
| AudioClip | An AudioClip representation of the audio asset. |
ToAudioClipAsync(IAudioAsset)
Converts an IAudioAsset to a Unity AudioClip asynchronously.
Declaration
public static UniTask<AudioClip> ToAudioClipAsync(this IAudioAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IAudioAsset | d | The audio asset to convert. |
Returns
| Type | Description |
|---|---|
| UniTask<AudioClip> | A task that returns an AudioClip representation of the audio asset. |
ToAudioClipPayload(AudioClip, string, AudioEncoding, int, int)
Converts an AudioClip to an AudioClipPayload with specified encoding and audio parameters.
Declaration
public static AudioClipAsset ToAudioClipPayload(this AudioClip audioClip, string path, AudioEncoding encoding, int sampleRate, int channels)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioClip | audioClip | The AudioClip to convert. |
| string | path | The file path associated with the audio clip. |
| AudioEncoding | encoding | The audio encoding format. |
| int | sampleRate | The sample rate of the audio. |
| int | channels | The number of audio channels. |
Returns
| Type | Description |
|---|---|
| AudioClipAsset | An AudioClipPayload containing the audio clip and metadata. |
ToAudioClipPayload(AudioClip, string, AudioFormat)
Converts an AudioClip to an AudioClipPayload using an AudioFormat specification.
Declaration
public static AudioClipAsset ToAudioClipPayload(this AudioClip audioClip, string path, AudioFormat format)
Parameters
| Type | Name | Description |
|---|---|---|
| AudioClip | audioClip | The AudioClip to convert. |
| string | path | The file path associated with the audio clip. |
| AudioFormat | format | The audio format specification containing encoding and audio parameters. |
Returns
| Type | Description |
|---|---|
| AudioClipAsset | An AudioClipPayload containing the audio clip and metadata. |
ToSprite(IImageAsset)
Converts an IImageAsset to a Unity Sprite synchronously.
Declaration
public static Sprite ToSprite(this IImageAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IImageAsset | d | The image asset to convert. |
Returns
| Type | Description |
|---|---|
| Sprite | A Sprite created from the image asset, or null if conversion fails. |
ToSpriteAsync(IImageAsset)
Converts an IImageAsset to a Unity Sprite asynchronously.
Declaration
public static UniTask<Sprite> ToSpriteAsync(this IImageAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IImageAsset | d | The image asset to convert. |
Returns
| Type | Description |
|---|---|
| UniTask<Sprite> | A task that returns a Sprite created from the image asset, or null if conversion fails. |
ToTexture2D(IImageAsset)
Converts an IImageAsset to a Unity Texture2D synchronously.
Declaration
public static Texture2D ToTexture2D(this IImageAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IImageAsset | d | The image asset to convert. |
Returns
| Type | Description |
|---|---|
| Texture2D | A Texture2D representation of the image asset. |
ToTexture2D(IImageChunk)
Converts an IImageChunk to a Unity Texture2D synchronously.
Declaration
public static Texture2D ToTexture2D(this IImageChunk c)
Parameters
| Type | Name | Description |
|---|---|---|
| IImageChunk | c | The image chunk to convert. |
Returns
| Type | Description |
|---|---|
| Texture2D | A Texture2D representation of the image chunk. |
Remarks
This method will attempt to convert the IImageChunk to a Texture2D. If the chunk is not an IImageAsset, the conversion may fail or return null.
ToTexture2DAsync(IImageAsset)
Converts an IImageAsset to a Unity Texture2D asynchronously.
Declaration
public static UniTask<Texture2D> ToTexture2DAsync(this IImageAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IImageAsset | d | The image asset to convert. |
Returns
| Type | Description |
|---|---|
| UniTask<Texture2D> | A task that returns a Texture2D representation of the image asset. |
ToTexture2DAsync(IImageChunk)
Converts an IImageChunk to a Unity Texture2D asynchronously.
Declaration
public static UniTask<Texture2D> ToTexture2DAsync(this IImageChunk c)
Parameters
| Type | Name | Description |
|---|---|---|
| IImageChunk | c | The image chunk to convert. |
Returns
| Type | Description |
|---|---|
| UniTask<Texture2D> | A task that returns a Texture2D representation of the image chunk. |
Remarks
This method will attempt to convert the IImageChunk to a Texture2D. If the chunk is not an IImageAsset, the conversion may fail or return null.
ToTexture2DPayload(Texture2D, string, ImageEncoding)
Converts a Texture2D to a Texture2DPayload with specified encoding.
Declaration
public static Texture2DAsset ToTexture2DPayload(this Texture2D texture, string path, ImageEncoding encoding)
Parameters
| Type | Name | Description |
|---|---|---|
| Texture2D | texture | The Texture2D to convert. |
| string | path | The file path associated with the texture. |
| ImageEncoding | encoding | The image encoding format. |
Returns
| Type | Description |
|---|---|
| Texture2DAsset | A Texture2DPayload containing the texture and metadata. |
ToVideoTexture(IVideoAsset)
Converts an IVideoAsset to a Unity VideoTexture synchronously.
Declaration
public static VideoTexture ToVideoTexture(this IVideoAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IVideoAsset | d | The video asset to convert. |
Returns
| Type | Description |
|---|---|
| VideoTexture | A VideoTexture representation of the video asset. |
ToVideoTextureAsync(IVideoAsset)
Converts an IVideoAsset to a Unity VideoTexture asynchronously.
Declaration
public static UniTask<VideoTexture> ToVideoTextureAsync(this IVideoAsset d)
Parameters
| Type | Name | Description |
|---|---|---|
| IVideoAsset | d | The video asset to convert. |
Returns
| Type | Description |
|---|---|
| UniTask<VideoTexture> | A task that returns a VideoTexture representation of the video asset. |