Table of Contents

Class Layer

Namespace
PAC.Layers

An abstract class to define what each type of layer must have.

public abstract class Layer
Inheritance
Layer
Derived
Inherited Members

Constructors

Layer(Layer)

public Layer(Layer layer)

Parameters

layer Layer

Layer(string, Texture2D)

public Layer(string name, Texture2D texture)

Parameters

name string
texture Texture2D

Fields

_blendMode

protected BlendMode _blendMode

Field Value

BlendMode

_visible

protected bool _visible

Field Value

bool

onPixelsChanged

Called when the SetPixel() or SetPixels() has been called. Passes the array of pixels changed and the frames it was called on.

protected UnityEvent<IntVector2[], int[]> onPixelsChanged

Field Value

UnityEvent<IntVector2[], int[]>

Properties

this[int]

Returns the texture of the most recent key frame before or at the frame index. Same as GetTexture(frame).

public AnimationKeyFrame this[int frame] { get; }

Parameters

frame int

Property Value

AnimationKeyFrame

blendMode

public BlendMode blendMode { get; set; }

Property Value

BlendMode

height

public int height { get; protected set; }

Property Value

int

keyFrameIndices

The frame indices of the key frames in the animation, in order.

public int[] keyFrameIndices { get; }

Property Value

int[]

keyFrameTextures

The textures of the key frames in the animation, in order.

public Texture2D[] keyFrameTextures { get; }

Property Value

Texture2D[]

keyFrames

The key frames of the animation, in order.

public List<AnimationKeyFrame> keyFrames { get; protected set; }

Property Value

List<AnimationKeyFrame>

layerType

public abstract LayerType layerType { get; }

Property Value

LayerType

locked

public bool locked { get; set; }

Property Value

bool

name

public string name { get; set; }

Property Value

string

opacity

public float opacity { get; set; }

Property Value

float

rect

public IntRect rect { get; }

Property Value

IntRect

visible

public bool visible { get; set; }

Property Value

bool

width

public int width { get; protected set; }

Property Value

int

Methods

AddKeyFrame(AnimationKeyFrame)

Adds the given key frame. Returns true if it replaces an existing key frame, and false otherwise.

protected bool AddKeyFrame(AnimationKeyFrame keyFrame)

Parameters

keyFrame AnimationKeyFrame

Returns

bool

AddKeyFrame(int)

Adds a key frame at frame frame. The texture will be that of the most recent key frame. Returns true if it replaces an existing key frame, and false otherwise.

protected bool AddKeyFrame(int frame)

Parameters

frame int

Returns

bool

AddKeyFrame(int, Texture2D)

Adds a key frame with the given texture at frame frame. Returns true if it replaces an existing key frame, and false otherwise.

protected bool AddKeyFrame(int frame, Texture2D texture)

Parameters

frame int
texture Texture2D

Returns

bool

ClearFrames()

Deletes all key frames.

public abstract void ClearFrames()

DeepCopy()

Creates a deep copy of the Layer.

public abstract Layer DeepCopy()

Returns

Layer

DeleteKeyFrame(AnimationKeyFrame)

Deletes the given key frame, if it's in the animation, in which case it returns true. Otherwise it returns false.

public bool DeleteKeyFrame(AnimationKeyFrame keyFrame)

Parameters

keyFrame AnimationKeyFrame

Returns

bool

DeleteKeyFrame(int)

public AnimationKeyFrame DeleteKeyFrame(int keyFrame)

Parameters

keyFrame int

Returns

AnimationKeyFrame

DeleteKeyFrameNoEvent(int)

Deletes the key frame at the given frame index, if there is one, in which case it returns that key frame. Otherwise it returns null.

protected abstract AnimationKeyFrame DeleteKeyFrameNoEvent(int keyframe)

Parameters

keyframe int

Returns

AnimationKeyFrame

DeleteMostRecentKeyFrame(int)

Deletes the most recent key frame before or at the given frame index and returns that key frame.

public AnimationKeyFrame DeleteMostRecentKeyFrame(int frame)

Parameters

frame int

Returns

AnimationKeyFrame

Extend(int, int, int, int)

Extends the dimensions of the layer in each direction by the given amounts.

public void Extend(int left, int right, int up, int down)

Parameters

left int
right int
up int
down int

ExtendNoEvent(int, int, int, int)

Extends the dimensions of the layer in each direction by the given amounts, but does not invoke the onPixelsChanged event.

protected abstract void ExtendNoEvent(int left, int right, int up, int down)

Parameters

left int
right int
up int
down int

Flip(FlipDirection)

Flips the layer.

public void Flip(FlipDirection direction)

Parameters

direction FlipDirection

FlipNoEvent(FlipDirection)

Flips the layer, but does not invoke the onPixelsChanged event.

protected abstract void FlipNoEvent(FlipDirection direction)

Parameters

direction FlipDirection

GetJsonConverterSet(SemanticVersion)

public static JsonConversion.JsonConverterSet GetJsonConverterSet(SemanticVersion fromJsonFileFormatVersion)

Parameters

fromJsonFileFormatVersion SemanticVersion

Returns

JsonConversion.JsonConverterSet

GetKeyFrame(int)

Returns the most recent key frame before or at the frame index - i.e. the key frame the animation will play at the frame index.

public AnimationKeyFrame GetKeyFrame(int frame)

Parameters

frame int

Returns

AnimationKeyFrame

GetPixel(IntVector2, int, bool)

Gets the colour of the pixel.

public abstract Color GetPixel(IntVector2 pixel, int frame, bool useLayerOpacity = true)

Parameters

pixel IntVector2
frame int
useLayerOpacity bool

Returns

Color

GetPixel(int, int, int, bool)

Gets the colour of the pixel (x, y).

public Color GetPixel(int x, int y, int frame, bool useLayerOpacity = true)

Parameters

x int
y int
frame int
useLayerOpacity bool

Returns

Color

HasKeyFrameAt(int)

Returns whether or not there is a key frame at the given frame index.

public bool HasKeyFrameAt(int frame)

Parameters

frame int

Returns

bool

IsBlank()

Returns true if and only if all pixels are completely transparent.

public bool IsBlank()

Returns

bool

Rotate(RotationAngle)

Rotates the layer. Rotation is clockwise.

public void Rotate(RotationAngle angle)

Parameters

angle RotationAngle

RotateNoEvent(RotationAngle)

Rotates the layer, but does not invoke the onPixelsChanged event. Rotation is clockwise.

protected abstract void RotateNoEvent(RotationAngle angle)

Parameters

angle RotationAngle

Scale(int, int)

Resizes the dimensions of the file by the scale factor.

public void Scale(int newWidth, int newHeight)

Parameters

newWidth int
newHeight int

Scale(float)

Resizes the dimensions of the file by the scale factor.

public void Scale(float scaleFactor)

Parameters

scaleFactor float

Scale(float, float)

Resizes the dimensions of the file by the scale factors.

public void Scale(float xScaleFactor, float yScaleFactor)

Parameters

xScaleFactor float
yScaleFactor float

ScaleNoEvent(int, int)

Resizes the dimensions to the new width and height, but does not invoke the onPixelsChanged event.

protected abstract void ScaleNoEvent(int newWidth, int newHeight)

Parameters

newWidth int
newHeight int

ScaleNoEvent(float, float)

Resizes the dimensions of the file by the scale factors, but does not invoke the onPixelsChanged event.

protected abstract void ScaleNoEvent(float xScaleFactor, float yScaleFactor)

Parameters

xScaleFactor float
yScaleFactor float

SetPixel(IntVector2, int, Color, AnimFrameRefMode)

Sets the colour of the pixel. Throws an error if the pixel is outside the layer.

public IntVector2[] SetPixel(IntVector2 pixel, int frame, Color colour, AnimFrameRefMode frameRefMode)

Parameters

pixel IntVector2
frame int
colour Color
frameRefMode AnimFrameRefMode

Returns

IntVector2[]

SetPixel(int, int, int, Color, AnimFrameRefMode)

Sets the colour of the pixel (x, y). Throws an error if the pixel is outside the layer.

public IntVector2[] SetPixel(int x, int y, int frame, Color colour, AnimFrameRefMode frameRefMode)

Parameters

x int
y int
frame int
colour Color
frameRefMode AnimFrameRefMode

Returns

IntVector2[]

SetPixels(IntVector2[], int, Color, AnimFrameRefMode)

Sets the colour of the pixels. Throws an error if a pixel is outside the layer.

public IntVector2[] SetPixels(IntVector2[] pixels, int frame, Color colour, AnimFrameRefMode frameRefMode)

Parameters

pixels IntVector2[]
frame int
colour Color
frameRefMode AnimFrameRefMode

Returns

IntVector2[]

SetPixelsNoEvent(IntVector2[], int, Color, AnimFrameRefMode)

Sets the colour of the pixels. You do not need to check the pixels are in the layer as this check is done in Layer.SetPixels(), which is the only way this method is called.

protected abstract IntVector2[] SetPixelsNoEvent(IntVector2[] pixels, int frame, Color colour, AnimFrameRefMode frameRefMode)

Parameters

pixels IntVector2[]
frame int
colour Color
frameRefMode AnimFrameRefMode

Returns

IntVector2[]

SubscribeToOnBlendModeChanged(UnityAction)

public void SubscribeToOnBlendModeChanged(UnityAction call)

Parameters

call UnityAction

SubscribeToOnKeyFrameAdded(UnityAction<int>)

public void SubscribeToOnKeyFrameAdded(UnityAction<int> call)

Parameters

call UnityAction<int>

SubscribeToOnKeyFrameRemoved(UnityAction<int>)

public void SubscribeToOnKeyFrameRemoved(UnityAction<int> call)

Parameters

call UnityAction<int>

SubscribeToOnPixelsChanged(UnityAction<IntVector2[], int[]>)

public void SubscribeToOnPixelsChanged(UnityAction<IntVector2[], int[]> call)

Parameters

call UnityAction<IntVector2[], int[]>

SubscribeToOnVisibilityChanged(UnityAction)

public void SubscribeToOnVisibilityChanged(UnityAction call)

Parameters

call UnityAction