Swapping Sprite Library Assets | 2D Animation | 3.0.8
docs.unity3d.com
    Show / Hide Table of Contents

    Swapping Sprite Library Assets

    When you need to make a bigger visual change to a Sprite model (for example, switching colors for a character depending on which team it is on), you can use the method detailed in Changing part of a character’s appearance for each individual Sprite on the model.

    However, if there are a large number of Sprites you want to change, there is a quicker method that requires additional setup, but allows for a more efficient way to swap all Sprites at once. With this method, you create another Sprite Library Asset with the alternative Sprites, then in the Sprite Library component, swap the Sprite Library Asset to the one that contains the alternative Sprites.

    The following example uses one set of Sprites that are in color, and one set of identical Sprites that are in greyscale.

    Example character in color in the left-hand image, and in greyscale in the right-hand image.

    Below is the example workflow for the setup of an additional Sprite Library Asset and how to swap the original Library with it.

    1. In your image editor (such as Photoshop), create two versions of the Sprites you need to use. In this example, one is set in color, and the other is set in greyscale.

    2. Import the PSB files for each character into Unity. Both appear in the Asset window as separate Prefabs. If your files are not in the PSB format, refer to the steps in Sprite Swap manual setup to manually set up your Sprite Library Assets.

    3. In the Skinning Editor, assign each part of the characters to a unique Category (for example, create a ‘Left Hand’ category for the ‘left hand’ Sprite, and so on).

    4. Make sure the corresponding Sprite parts in both Prefabs have the same Category name and Label as their counterpart. For example, the head Sprites of both the color and greyscale characters must be in the same ‘Head’ Category and have the same Label.

      The Category and Label setup for the colorful character.

      The Category and Label setup for the greyscale character.

    5. Drag the Prefab for the colorful character into the Scene. In the Inspector window, navigate to its Sprite Library component.

    6. Next, select the Prefab for the character in greyscale. Drag the Sprite Library Asset from its Sprite Library component’s Sprite Library Asset field, and drop it into the colorful character’s corresponding __Sprite Library Asset __field. This replaces the Asset that was already assigned to it.

    7. The colorful character’s Sprites should now have switched to their greyscale counterparts in the greyscale character’s Sprite Library Asset.

    Known issue: Because Unity automatically generates the default Sprite Library Asset as a sub-Asset of the Prefabs, both Sprite Library Assets have identical names, and you cannot rename them.

    Back to top
    Copyright © 2023 Unity Technologies — Terms of use
    • Legal
    • Privacy Policy
    • Cookies
    • Do Not Sell or Share My Personal Information
    • Your Privacy Choices (Cookie Settings)
    "Unity", Unity logos, and other Unity trademarks are trademarks or registered trademarks of Unity Technologies or its affiliates in the U.S. and elsewhere (more info here). Other names or brands are trademarks of their respective owners.
    Generated by DocFX on 18 October 2023