SpriteRendererTextureSwap Class

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
DefaultExecutionOrder

Fields

Name Constant Value Summary
DefaultExecutionOrder 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 SecondarySpriteTexture[]
The replacement for the original UnityEngine.Sprite.GetSecondaryTextures(UnityEngine.SecondarySpriteTexture[]).
SwapSecondaryTextures 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(Dictionary<Sprite, Sprite>) void
Destroys all the System.Collections.Generic.Dictionary`2.Values.
static
DestroySprites(Texture2D) void
Destroys all sprites created for the `texture`.
static
GetSecondaryTextures(Sprite) SecondarySpriteTexture[]
A wrapper around UnityEngine.Sprite.GetSecondaryTextures(UnityEngine.SecondarySpriteTexture[]).
static
GetSecondaryTexturesCached(Sprite) SecondarySpriteTexture[]
A wrapper around UnityEngine.Sprite.GetSecondaryTextures(UnityEngine.SecondarySpriteTexture[]) which reuses arrays of the same size.
static
GetSpriteMap(Texture2D) Dictionary<Sprite, Sprite>
Returns a cached dictionary mapping original sprites to duplicates using the specified `texture`.
static
LateUpdate() void
OnValidate() void
TrySwapTexture(Dictionary<Sprite, Sprite>, Texture2D, SecondarySpriteTexture[], Sprite) 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