API Reference¶
This section documents the current public C# API in Unity/Uniasset/. It focuses on the high-level wrappers and excludes Unsafe / Interop types.
Namespace overview¶
| Namespace | Description |
|---|---|
Uniasset |
Core stream interfaces and adapters |
Uniasset.Image |
Image-related types |
Uniasset.Audio |
Audio-related types |
Core types¶
ImageAsset¶
An image asset wrapper that can load encoded image data from files, memory, or streams, then crop, resize, clone, and convert it to Texture2D.
using var image = new ImageAsset();
image.Load("photo.png");
Texture2D texture = image.ToTexture2D();
AudioAsset¶
An audio asset wrapper that can load audio from files, memory, or custom streams, then expose PCM reads, seeking, and AudioClip conversion.
CropOptions¶
A struct that describes a crop rectangle for batch cropping.
var crops = new CropOptions[]
{
new CropOptions(0, 0, 100, 100),
new CropOptions(100, 0, 100, 100),
};
ImageAsset[] results = image.CropMultiple(crops);
ResizeFilter¶
An enum that selects the resize filter, including Nearest, Box, Lanczos3, and Gaussian.
PixelType¶
An enum describing the image pixel layout.
SampleFormat¶
An enum describing the sample format used during audio decode, supporting Float and Int16.
IUniassetStream¶
The custom stream interface.
public interface IUniassetStream
{
int Read(Span<byte> buffer);
long Seek(long offset, SeekOrigin origin);
}
StreamWrapper¶
The adapter from System.IO.Stream to IUniassetStream.
Usage patterns¶
Synchronous loading¶
Asynchronous loading¶
Releasing resources¶
ImageAsset and AudioAsset both implement IDisposable and should be released promptly:
using var image = new ImageAsset();
image.Load("photo.png");
Texture2D texture = image.ToTexture2D();
Type list¶
| Type | Namespace | Description |
|---|---|---|
ImageAsset |
Uniasset.Image |
Image loading, processing, and conversion |
CropOptions |
Uniasset.Image |
Batch crop parameters |
ResizeFilter |
Uniasset.Image |
Resize filter algorithm |
PixelType |
Uniasset.Image |
Pixel format |
AudioAsset |
Uniasset.Audio |
Audio loading, reading, and conversion |
SampleFormat |
Uniasset.Audio |
Audio sample format |
IUniassetStream |
Uniasset |
Custom stream interface |
SeekOrigin |
Uniasset |
Stream seek reference |
StreamWrapper |
Uniasset |
System.IO.Stream adapter |