Class SpriteManager
Class for managing loading and caching Sprites from png files.
Inheritance
SpriteManager
Assembly: ItemChanger.dll
Syntax
public class SpriteManager
Constructors
View Source
SpriteManager(Assembly, string)
Creates a SpriteManager to lazily load and cache Sprites from the embedded png files in the specified assembly.
Only filepaths with the matching prefix are considered, and the prefix is removed to determine sprite names (e.g. "ItemChangerMod.Resources." is the prefix for Instance).
Images will be loaded with default Bilinear filter mode and 100 pixels per unit.
Declaration
public SpriteManager(Assembly a, string resourcePrefix)
Parameters
View Source
SpriteManager(Assembly, string, Info)
Creates a SpriteManager to lazily load and cache Sprites from the embedded png files in the specified assembly.
Only filepaths with the matching prefix are considered, and the prefix is removed to determine sprite names (e.g. "ItemChangerMod.Resources." is the prefix for Instance).
Declaration
public SpriteManager(Assembly a, string resourcePrefix, SpriteManager.Info info)
Parameters
Properties
View Source
Instance
The SpriteManager with access to embedded ItemChanger pngs, constructed with the ItemChanger assembly and prefix "ItemChanger.Resources."
Declaration
public static SpriteManager Instance { get; }
Property Value
Methods
View Source
GetSprite(string)
Fetches the Sprite with the specified name. If it has not yet been loaded, loads it from embedded resources and caches the result.
The name is the path of the image as an embedded resource, with the SpriteManager prefix and file extension removed.
For example, the image at "ItemChanger.Resources.ShopIcons.Geo.png" has key "ShopIcons.Geo" in SpriteManager.Instance.
Declaration
public Sprite GetSprite(string name)
Parameters
| Type |
Name |
Description |
| string |
name |
|
Returns
View Source
Load(byte[], FilterMode)
Loads a sprite from the png file passed as a byte array.
Declaration
public static Sprite Load(byte[] data, FilterMode filterMode)
Parameters
Returns
View Source
Load(byte[], FilterMode, float)
Declaration
public static Sprite Load(byte[] data, FilterMode filterMode, float pixelsPerUnit)
Parameters
Returns
View Source
Load(Stream, FilterMode)
Loads a sprite from the png file passed as a stream.
Declaration
public static Sprite Load(Stream data, FilterMode filterMode = 1)
Parameters
Returns
Extension Methods