Table of Contents

Class ImageUtils

Namespace
S1API.Utils
Assembly
S1API.dll

A utility class to assist with loading images into the game. Useful for icons such as on phone apps, custom NPCs, quests, etc. This class is intended for public use by mod developers.

public static class ImageUtils
Inheritance
ImageUtils
Inherited Members

Methods

LoadImage(string)

Loads an image from the specified file path and converts it into a Sprite object.

public static Sprite? LoadImage(string fileName)

Parameters

fileName string

The name of the file (with path) containing the image to load.

Returns

Sprite

A Sprite object representing the loaded image, or null if the image could not be loaded or the file does not exist.

LoadImageFromResource(Assembly, string, float, FilterMode)

Loads an image from an embedded resource stream and converts it into a Sprite object.

public static Sprite? LoadImageFromResource(Assembly assembly, string resourceName, float pixelsPerUnit = 100, FilterMode filterMode = 1)

Parameters

assembly Assembly

The assembly containing the embedded resource.

resourceName string

The fully qualified name of the embedded resource (e.g., "Namespace.Assets.Icon.png").

pixelsPerUnit float

The pixels per unit for the sprite. Defaults to 100f.

filterMode FilterMode

The filter mode for the texture. Defaults to FilterMode.Bilinear.

Returns

Sprite

A Sprite object representing the loaded image, or null if the resource could not be found or loaded.

LoadImageRaw(byte[])

Loads an image from a byte array and converts it into a Sprite object.

public static Sprite? LoadImageRaw(byte[] data)

Parameters

data byte[]

The byte array containing the image data to load.

Returns

Sprite

A Sprite object representing the loaded image, or null if the image could not be loaded.

TextureToSprite(Texture2D?, float)

Converts a Texture2D to a Sprite.

public static Sprite? TextureToSprite(Texture2D? texture, float pixelsPerUnit = 100)

Parameters

texture Texture2D

The texture to convert.

pixelsPerUnit float

The pixels per unit for the sprite. Defaults to 100f.

Returns

Sprite

A Sprite object, or null if texture is null.