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.
Inheritance
SpriteLibrary
Inherited Members
UnityEngine.MonoBehaviour.StartCoroutine_Auto(System.Collections.IEnumerator)
UnityEngine.Component.GetComponent<T>()
UnityEngine.Component.TryGetComponent(System.Type, UnityEngine.Component)
UnityEngine.Component.TryGetComponent<T>(T)
UnityEngine.Component.GetComponentInChildren<T>(System.Boolean)
UnityEngine.Component.GetComponentInChildren<T>()
UnityEngine.Component.GetComponentsInChildren(System.Type)
UnityEngine.Component.GetComponentsInChildren<T>(System.Boolean)
UnityEngine.Component.GetComponentsInChildren<T>(System.Boolean, System.Collections.Generic.List<T>)
UnityEngine.Component.GetComponentsInChildren<T>()
UnityEngine.Component.GetComponentsInChildren<T>(System.Collections.Generic.List<T>)
UnityEngine.Component.GetComponentInParent<T>(System.Boolean)
UnityEngine.Component.GetComponentInParent<T>()
UnityEngine.Component.GetComponentsInParent(System.Type)
UnityEngine.Component.GetComponentsInParent<T>(System.Boolean)
UnityEngine.Component.GetComponentsInParent<T>(System.Boolean, System.Collections.Generic.List<T>)
UnityEngine.Component.GetComponentsInParent<T>()
UnityEngine.Component.GetComponents(System.Type, System.Collections.Generic.List<UnityEngine.Component>)
UnityEngine.Component.GetComponents<T>(System.Collections.Generic.List<T>)
UnityEngine.Component.GetComponents<T>()
UnityEngine.Object.GetHashCode()
UnityEngine.Object.Equals(System.Object)
UnityEngine.Object.Instantiate<T>(T)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Vector3, UnityEngine.Quaternion, UnityEngine.Transform)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Transform)
UnityEngine.Object.Instantiate<T>(T, UnityEngine.Transform, System.Boolean)
UnityEngine.Object.DestroyObject(UnityEngine.Object, System.Single)
UnityEngine.Object.DestroyObject(UnityEngine.Object)
UnityEngine.Object.FindSceneObjectsOfType(System.Type)
UnityEngine.Object.FindObjectsOfType<T>()
UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsSortMode)
UnityEngine.Object.FindObjectsOfType<T>(System.Boolean)
UnityEngine.Object.FindObjectsByType<T>(UnityEngine.FindObjectsInactive, UnityEngine.FindObjectsSortMode)
UnityEngine.Object.FindObjectOfType<T>()
UnityEngine.Object.FindObjectOfType<T>(System.Boolean)
UnityEngine.Object.FindFirstObjectByType<T>()
UnityEngine.Object.FindAnyObjectByType<T>()
UnityEngine.Object.FindFirstObjectByType<T>(UnityEngine.FindObjectsInactive)
UnityEngine.Object.FindAnyObjectByType<T>(UnityEngine.FindObjectsInactive)
Syntax
[DisallowMultipleComponent]
[AddComponentMenu("2D Animation/Sprite Library")]
[Icon("Packages/com.unity.2d.animation/Editor/Assets/ComponentIcons/Animation.SpriteLibrary.png")]
[MovedFrom("UnityEngine.Experimental.U2D.Animation")]
[HelpURL("https://docs.unity3d.com/Packages/com.unity.2d.animation@latest/index.html?subfolder=/manual/SL-component.html")]
public class SpriteLibrary : MonoBehaviour, IPreviewable
Properties
spriteLibraryAsset
Get or Set the current SpriteLibraryAsset to use.
Declaration
public SpriteLibraryAsset spriteLibraryAsset { get; set; }
Property Value
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 |
SpriteLibraryAsset |
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 |
SpriteLibraryAsset |
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
Type |
Name |
Description |
String |
category |
Category name.
|
String |
label |
Label name.
|
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
Type |
Name |
Description |
String |
category |
Category name.
|
String |
label |
Label name.
|
Returns
Type |
Description |
Boolean |
True if override exist, false otherwise.
|
OnPreviewUpdate()
Empty method. Implemented for the IPreviewable interface.
Declaration
public void OnPreviewUpdate()
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)
Parameters
Type |
Name |
Description |
String |
category |
Category to remove.
|
String |
label |
Label to remove.
|
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.