Summary
Replaces the
UnityEngine.SpriteRenderer.sprite
with a copy of it that uses a different Animancer.SpriteRendererTextureSwap.Texture
during every Animancer.SpriteRendererTextureSwap.LateUpdate
.
- Assembly
- Animancer
.dll - Namespace
- Animancer
- Base Types
-
- MonoBehaviour
graph BT
Type-->Base0["MonoBehaviour"]
Type["SpriteRendererTextureSwap"]
class Type type-node
Syntax
[AddComponentMenu("Animancer/Sprite Renderer Texture Swap")]
[HelpURL("https://kybernetik.com.au/animancer/api/Animancer/" + nameof(SpriteRendererTextureSwap))]
[DefaultExecutionOrder(DefaultExecutionOrder)]
public class SpriteRendererTextureSwap : MonoBehaviour
Remarks
This script is not specific to Animancer and will work with any animation system.
Attributes
Type | Description |
---|---|
AddComponentMenu | |
HelpURLAttribute | |
Default |
Fields
Name | Constant Value | Summary |
---|---|---|
Default |
30000 |
Execute very late (32000 is last).
static
|
Properties
Name | Value | Summary |
---|---|---|
Renderer | SpriteRenderer |
The
UnityEngine.SpriteRenderer that will have its UnityEngine.Sprite modified. |
SecondaryTextures | Secondary |
The replacement for the original
UnityEngine.Sprite.GetSecondaryTextures(UnityEngine.SecondarySpriteTexture[]) . |
Swap |
bool |
Should the secondary textures be swapped as well?
|
Texture | Texture2D |
The replacement for the original
UnityEngine.Sprite.texture . |
Methods
Name | Value | Summary |
---|---|---|
Awake |
void | |
ClearCache |
void |
Destroys all sprites created for the current
Animancer.SpriteRendererTextureSwap.Texture . |
DestroySprites |
void |
Destroys all the
System.Collections.Generic.Dictionary`2.Values .static
|
DestroySprites |
void |
Destroys all sprites created for the `texture`.
static
|
GetSecondaryTextures |
Secondary |
A wrapper around
UnityEngine.Sprite.GetSecondaryTextures(UnityEngine.SecondarySpriteTexture[]) .static
|
Get |
Secondary |
A wrapper around
UnityEngine.Sprite.GetSecondaryTextures(UnityEngine.SecondarySpriteTexture[]) which reuses arrays of the same size.static
|
GetSpriteMap |
Dictionary |
Returns a cached dictionary mapping original sprites to duplicates using the specified `texture`.
static
|
LateUpdate |
void | |
OnValidate |
void | |
TrySwapTexture |
bool |
If the
UnityEngine.Sprite.texture is not already using the specified `texture`, this method replaces the
`sprite` with a cached duplicate which uses that `texture` instead.
static
|