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")]
[DefaultExecutionOrder(-2)]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.animation@7.0/manual/SLAsset.html#sprite-resolver-component")]
[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 |
ResolveSpriteToSpriteRenderer()
Set the Sprite in SpriteResolver to the SpriteRenderer component that is in the same GameObject.
Declaration
public void ResolveSpriteToSpriteRenderer()
SetCategoryAndLabel(string, string)
Set the Category and label to use
Declaration
public void SetCategoryAndLabel(string category, string label)
Parameters
| Type | Name | Description |
|---|---|---|
| string | category | Category to use |
| string | label | Label to use |
Events
onDeserializedCallback
Raised when object is deserialized in the Editor.
Declaration
public event Action onDeserializedCallback
Event Type
| Type | Description |
|---|---|
| Action |