Show / Hide Table of Contents

Class RetroSprite

Represents a sprite that's editable in the sprite editor window and contains all the data that's required by the editor.

Inheritance
System.Object
UnityEngine.Object
UnityEngine.ScriptableObject
RetroSprite
Namespace: InsaneScatterbrain.RetroKit.Editor
Syntax
public class RetroSprite : ScriptableObject

Fields

layers

The layers the sprite consists of.

Declaration
public List<Layer> layers
Field Value
Type Description
System.Collections.Generic.List<Layer>

size

The sprite's size in pixels.

Declaration
public Vector2Int size
Field Value
Type Description
UnityEngine.Vector2Int

sprite

The Unity sprite used to display this retro sprite.

Declaration
public Sprite sprite
Field Value
Type Description
UnityEngine.Sprite

Methods

Apply()

Apply changes to the texture and save them.

Declaration
public void Apply()

ApplyPalette(Color[])

Apply palette to retro sprite and it's texture.

Declaration
public void ApplyPalette(Color[] palette)
Parameters
Type Name Description
UnityEngine.Color[] palette

The color palette.

Create(String, RetroSprite, Color[])

Creates a copy of the existing retro sprite, with a new name.

Declaration
public static RetroSprite Create(string name, RetroSprite existingRetroSprite, Color[] palette)
Parameters
Type Name Description
System.String name

The name.

RetroSprite existingRetroSprite

The existing retro sprite to copy.

UnityEngine.Color[] palette

The active palette.

Returns
Type Description
RetroSprite

The new retro sprite.

Create(String, Int32, Int32, Int32)

Creates a new retro sprite and it's default data.

Declaration
public static RetroSprite Create(string name, int width = 16, int height = 16, int ppu = 16)
Parameters
Type Name Description
System.String name

The name.

System.Int32 width

The sprite's width.

System.Int32 height

The sprite's height.

System.Int32 ppu

The pixels per unit.

Returns
Type Description
RetroSprite

The retro sprite.

GetColorIndex(Int32, Int32)

Gets the color index of the given pixel at the given index.

Declaration
public int GetColorIndex(int x, int y)
Parameters
Type Name Description
System.Int32 x

The x-coordinate.

System.Int32 y

The y-coordinate.

Returns
Type Description
System.Int32

The color index.

GetColorIndex(Vector2Int)

Gets the color index of the given pixel at the given index.

Declaration
public int GetColorIndex(Vector2Int pixelIndex)
Parameters
Type Name Description
UnityEngine.Vector2Int pixelIndex

The pixel's coordinates.

Returns
Type Description
System.Int32

The color index.

RegenerateAssets(Color[], Texture2D, out Sprite)

Regenerates the associated assets.

Declaration
public void RegenerateAssets(Color[] palette, Texture2D texture, out Sprite newSprite)
Parameters
Type Name Description
UnityEngine.Color[] palette

The used color palette.

UnityEngine.Texture2D texture

The texture to regenerate on.

UnityEngine.Sprite newSprite

The new sprite.

Resize(Int32, Int32, Color[])

Resizes the retro sprite and the texture associated with it. If the new size is smaller than the old one, the sprites get removed from the bottom and right size. In case of a bigger new size, the new pixels are added to the bottom and right.

Declaration
public Sprite Resize(int newWidth, int newHeight, Color[] palette)
Parameters
Type Name Description
System.Int32 newWidth

The new width.

System.Int32 newHeight

The new height.

UnityEngine.Color[] palette

The active palette.

Returns
Type Description
UnityEngine.Sprite

If the resize is performed the new Sprite instance, null otherwise.

SetColor(Int32, Int32, Int32, Color[])

Sets the color of the pixel at the given coordinates.

Declaration
public void SetColor(int x, int y, int colorIndex, Color[] palette)
Parameters
Type Name Description
System.Int32 x

The x-coordinate.

System.Int32 y

The y-coordinate.

System.Int32 colorIndex

The color index.

UnityEngine.Color[] palette

The color palette.

SetColor(Vector2Int, Int32, Color[])

Sets the color of the pixel at the given index.

Declaration
public void SetColor(Vector2Int index, int colorIndex, Color[] palette)
Parameters
Type Name Description
UnityEngine.Vector2Int index

The pixel's index.

System.Int32 colorIndex

The color index.

UnityEngine.Color[] palette

The color palette.

ToString()

Declaration
public override string ToString()
Returns
Type Description
System.String
Overrides
UnityEngine.Object.ToString()

UnsetColor(Int32, Int32)

Makes the pixel at the given coordinates transparent.

Declaration
public void UnsetColor(int x, int y)
Parameters
Type Name Description
System.Int32 x

The x-coordinate.

System.Int32 y

The y-coordinate.

Back to top Generated by DocFX