Class OutputExtensions
Extension methods for AIDevKit types.
Inherited Members
Namespace: Glitch9.AIDevKit
Assembly: Glitch9.AIDevKit.dll
Syntax
public static class OutputExtensions
Methods
| Edit this page View SourceGetInputUnityObjects<T>(UserMessage)
Extracts Unity objects of a specific type from the user message's input files and objects. Useful for displaying images or audio clips sent as part of the message in the UI.
Declaration
public static List<T> GetInputUnityObjects<T>(this UserMessage m) where T : Object
Parameters
| Type | Name | Description |
|---|---|---|
| UserMessage | m | The user message to extract objects from |
Returns
| Type | Description |
|---|---|
| List<T> | A list of Unity objects of type T found in the message, or null if the message is null |
Type Parameters
| Name | Description |
|---|---|
| T | The type of Unity object to extract (e.g., Texture2D, AudioClip, Sprite) |
ToAudioClip(UniTask<Generated<IAudioAsset>>)
Awaits the generated audio task and converts the result to an AudioClip.
Declaration
public static UniTask<AudioClip> ToAudioClip(this UniTask<Generated<IAudioAsset>> generatedTask)
Parameters
| Type | Name | Description |
|---|---|---|
| UniTask<Generated<IAudioAsset>> | generatedTask | The task that will produce a generated collection of IAudioData |
Returns
| Type | Description |
|---|---|
| UniTask<AudioClip> | A task that returns the first audio as an AudioClip, or null if not available |
ToAudioClip(Generated<IAudioAsset>)
Converts the first completed audio in the generated collection to an AudioClip.
Declaration
public static AudioClip ToAudioClip(this Generated<IAudioAsset> generated)
Parameters
| Type | Name | Description |
|---|---|---|
| Generated<IAudioAsset> | generated | The generated collection of IAudioData |
Returns
| Type | Description |
|---|---|
| AudioClip | The first completed audio as an AudioClip |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when the audio data is not completed |
ToAudioClipAsync(Generated<IAudioAsset>)
Asynchronously converts the first completed audio in the generated collection to an AudioClip.
Declaration
public static UniTask<AudioClip> ToAudioClipAsync(this Generated<IAudioAsset> generated)
Parameters
| Type | Name | Description |
|---|---|---|
| Generated<IAudioAsset> | generated | The generated collection of IAudioData |
Returns
| Type | Description |
|---|---|
| UniTask<AudioClip> | A task that returns the first completed audio as an AudioClip |
Exceptions
| Type | Condition |
|---|---|
| InvalidCastException | Thrown when the audio data is not completed |
ToSprite(UniTask<Generated<IImageAsset>>)
Awaits the generated image task and converts the result to a Sprite.
Declaration
public static UniTask<Sprite> ToSprite(this UniTask<Generated<IImageAsset>> generatedTask)
Parameters
| Type | Name | Description |
|---|---|---|
| UniTask<Generated<IImageAsset>> | generatedTask | The task that will produce a generated collection of IImageData |
Returns
| Type | Description |
|---|---|
| UniTask<Sprite> | A task that returns the first image as a Sprite, or null if not available |
ToSprite(Generated<IImageAsset>)
Converts the first Texture2D in the output to a Sprite, or returns null if not available.
Declaration
public static Sprite ToSprite(this Generated<IImageAsset> generated)
Parameters
| Type | Name | Description |
|---|---|---|
| Generated<IImageAsset> | generated | The generated collection of Texture2D |
Returns
| Type | Description |
|---|---|
| Sprite | The first Texture2D converted to a Sprite, or null if no Texture2D is present. |
ToSpriteAsync(Generated<IImageAsset>)
Asynchronously converts the first image in the generated collection to a Sprite.
Declaration
public static UniTask<Sprite> ToSpriteAsync(this Generated<IImageAsset> generated)
Parameters
| Type | Name | Description |
|---|---|---|
| Generated<IImageAsset> | generated | The generated collection of IImageData |
Returns
| Type | Description |
|---|---|
| UniTask<Sprite> | A task that returns the first image as a Sprite, or null if not available |
ToTexture2D(UniTask<Generated<IImageAsset>>)
Awaits the generated image task and converts the result to a Texture2D.
Declaration
public static UniTask<Texture2D> ToTexture2D(this UniTask<Generated<IImageAsset>> generatedTask)
Parameters
| Type | Name | Description |
|---|---|---|
| UniTask<Generated<IImageAsset>> | generatedTask | The task that will produce a generated collection of IImageData |
Returns
| Type | Description |
|---|---|
| UniTask<Texture2D> | A task that returns the first image as a Texture2D, or null if not available |
ToTexture2D(Generated<IImageAsset>)
Converts the first image in the generated collection to a Texture2D.
Declaration
public static Texture2D ToTexture2D(this Generated<IImageAsset> generated)
Parameters
| Type | Name | Description |
|---|---|---|
| Generated<IImageAsset> | generated | The generated collection of IImageData |
Returns
| Type | Description |
|---|---|
| Texture2D | The first image as a Texture2D, or null if not available |
ToTexture2DAsync(Generated<IImageAsset>)
Asynchronously converts the first image in the generated collection to a Texture2D.
Declaration
public static UniTask<Texture2D> ToTexture2DAsync(this Generated<IImageAsset> generated)
Parameters
| Type | Name | Description |
|---|---|---|
| Generated<IImageAsset> | generated | The generated collection of IImageData |
Returns
| Type | Description |
|---|---|
| UniTask<Texture2D> | A task that returns the first image as a Texture2D, or null if not available |
ToUploadRequest(UploadFileRequest)
Converts an UploadFileRequest to an UploadRequest.
Declaration
public static FileUploadRequest ToUploadRequest(this UploadFileRequest req)
Parameters
| Type | Name | Description |
|---|---|---|
| UploadFileRequest | req | The UploadFileRequest to convert |
Returns
| Type | Description |
|---|---|
| FileUploadRequest | An UploadRequest instance |