Class Layer
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
stringtexture
Texture2D
Fields
_blendMode
protected BlendMode _blendMode
Field Value
_visible
protected bool _visible
Field Value
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
blendMode
public BlendMode blendMode { get; set; }
Property Value
height
public int height { get; protected set; }
Property Value
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
layerType
public abstract LayerType layerType { get; }
Property Value
locked
public bool locked { get; set; }
Property Value
name
public string name { get; set; }
Property Value
opacity
public float opacity { get; set; }
Property Value
rect
public IntRect rect { get; }
Property Value
visible
public bool visible { get; set; }
Property Value
width
public int width { get; protected set; }
Property Value
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
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
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
inttexture
Texture2D
Returns
ClearFrames()
Deletes all key frames.
public abstract void ClearFrames()
DeepCopy()
Creates a deep copy of the Layer.
public abstract Layer DeepCopy()
Returns
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
DeleteKeyFrame(int)
public AnimationKeyFrame DeleteKeyFrame(int keyFrame)
Parameters
keyFrame
int
Returns
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
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
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
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
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
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
GetPixel(IntVector2, int, bool)
Gets the colour of the pixel.
public abstract Color GetPixel(IntVector2 pixel, int frame, bool useLayerOpacity = true)
Parameters
pixel
IntVector2frame
intuseLayerOpacity
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
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
IsBlank()
Returns true if and only if all pixels are completely transparent.
public bool IsBlank()
Returns
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
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
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
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
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
IntVector2frame
intcolour
ColorframeRefMode
AnimFrameRefMode
Returns
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
inty
intframe
intcolour
ColorframeRefMode
AnimFrameRefMode
Returns
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
intcolour
ColorframeRefMode
AnimFrameRefMode
Returns
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
intcolour
ColorframeRefMode
AnimFrameRefMode
Returns
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