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(Strings.MenuPrefix + "Sprite Renderer Texture Swap")]
[HelpURL(Strings.DocsURLs.APIDocumentation + "/" + nameof(SpriteRendererTextureSwap))]
[DefaultExecutionOrder(DefaultExecutionOrder)]
public class SpriteRendererTextureSwap : MonoBehaviour

Remarks

This script is not specific to Animancer and will work with any animation system if you remove the [UnityEngine.AddComponentMenu] and [HelpURL] attributes.

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.
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
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, 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