Class SpriteResolver
Updates a SpriteRenderer's Sprite reference on the Category and Label value it is set.
Implements
Inherited Members
Namespace: UnityEngine.U2D.Animation
Assembly: Unity.2D.Animation.Runtime.dll
Syntax
[ExecuteInEditMode]
[DisallowMultipleComponent]
[AddComponentMenu("2D Animation/Sprite Resolver")]
[Icon("Packages/com.unity.2d.animation/Editor/Assets/ComponentIcons/Animation.SpriteResolver.png")]
[DefaultExecutionOrder(-20)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.animation@latest/index.html?subfolder=/manual/SL-Resolver.html")]
[MovedFrom("UnityEngine.Experimental.U2D.Animation")]
public class SpriteResolver : MonoBehaviour, ISerializationCallbackReceiver
Remarks
By setting the SpriteResolver's Category and Label value, it will request for a Sprite from a SpriteLibrary Component the Sprite that is registered for the Category and Label. If a SpriteRenderer is present in the same GameObject, the SpriteResolver will update the SpriteRenderer's Sprite reference to the corresponding Sprite.
Properties
spriteLibrary
Property to get the SpriteLibrary the SpriteResolver is resolving from.
Declaration
public SpriteLibrary spriteLibrary { get; }
Property Value
Type | Description |
---|---|
SpriteLibrary |
Methods
GetCategory()
Get the Category set for the SpriteResolver.
Declaration
public string GetCategory()
Returns
Type | Description |
---|---|
string | The Category's name. |
GetLabel()
Get the Label set for the SpriteResolver.
Declaration
public string GetLabel()
Returns
Type | Description |
---|---|
string | The Label's name. |
OnPreviewUpdate()
Empty method. Implemented for the IPreviewable interface.
Declaration
public void OnPreviewUpdate()
ResolveSpriteToSpriteRenderer()
Set the Sprite in SpriteResolver to the SpriteRenderer component that is in the same GameObject.
Declaration
public bool ResolveSpriteToSpriteRenderer()
Returns
Type | Description |
---|---|
bool | True if it successfully resolved the Sprite. |
SetCategoryAndLabel(string, string)
Set the Category and label to use.
Declaration
public bool SetCategoryAndLabel(string category, string label)
Parameters
Type | Name | Description |
---|---|---|
string | category | Category to use. |
string | label | Label to use. |
Returns
Type | Description |
---|---|
bool | True if the Category and Label were successfully set. |
Events
onDeserializedCallback
Raised when object is deserialized in the Editor.
Declaration
public event Action onDeserializedCallback
Event Type
Type | Description |
---|---|
Action |