Class SpriteLibrary
Component that holds a Sprite Library Asset. The component is used by SpriteResolver Component to query for Sprite based on Category and Index
Inherited Members
Namespace: UnityEngine .U2D.Animation
Assembly: Unity.2D.Animation.Runtime.dll
Syntax
[DisallowMultipleComponent]
[AddComponentMenu("2D Animation/Sprite Library")]
[MovedFrom("UnityEngine.Experimental.U2D.Animation")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.animation@7.0/manual/SLAsset.html#sprite-library-component")]
public class SpriteLibrary : MonoBehaviour
Properties
spriteLibraryAsset
Get or Set the current SpriteLibraryAsset to use
Declaration
public SpriteLibraryAsset spriteLibraryAsset { get; set; }
Property Value
Type | Description |
---|---|
Sprite |
Methods
AddOverride(Sprite, string, string)
Add or replace an override when querying for the given Category and Label.
Declaration
public void AddOverride(Sprite sprite, string category, string label)
Parameters
Type | Name | Description |
---|---|---|
Sprite | sprite | Sprite to override to |
string | category | Category name to override |
string | label | Label name to override |
AddOverride(SpriteLibraryAsset, string)
Add or replace an override when querying for the given Category. All the categories in the Category will be added.
Declaration
public void AddOverride(SpriteLibraryAsset spriteLib, string category)
Parameters
Type | Name | Description |
---|---|---|
Sprite |
spriteLib | Sprite Library Asset to query |
string | category | Category name from the Sprite Library Asset to add override |
AddOverride(SpriteLibraryAsset, string, string)
Add or replace an override when querying for the given Category and Label from a SpriteLibraryAsset
Declaration
public void AddOverride(SpriteLibraryAsset spriteLib, string category, string label)
Parameters
Type | Name | Description |
---|---|---|
Sprite |
spriteLib | Sprite Library Asset to query |
string | category | Category name from the Sprite Library Asset to add override |
string | label | Label name to add override |
GetSprite(string, string)
Return the Sprite that is registered for the given Category and Label for the SpriteLibrary
Declaration
public Sprite GetSprite(string category, string label)
Parameters
Returns
Type | Description |
---|---|
Sprite | Sprite associated to the name and index |
HasOverride(string, string)
Method to check if a Category and Label pair has an override
Declaration
public bool HasOverride(string category, string label)
Parameters
Returns
Type | Description |
---|---|
bool | True if override exist, false otherwise |
RefreshSpriteResolvers()
Request SpriteResolver components that are in the same hierarchy to refresh
Declaration
public void RefreshSpriteResolvers()
RemoveOverride(string)
Remove all Sprite Library override for a given category
Declaration
public void RemoveOverride(string category)
Parameters
Type | Name | Description |
---|---|---|
string | category | Category overrides to remove |
RemoveOverride(string, string)
Remove Sprite Library override for a given category and label
Declaration
public void RemoveOverride(string category, string label)