Search Unity

  1. We are migrating the Unity Forums to Unity Discussions. On July 12, the Unity Forums will become read-only.

    Please, do not make any changes to your username or email addresses at during this transition time.

    It's still possible to reply to existing private message conversations during the migration, but any new replies you post will be missing after the main migration is complete. We'll do our best to migrate these messages in a follow-up step.

    On July 15, Unity Discussions will become read-only until July 18, when the new design and the migrated forum contents will go live.

    Read our full announcement for more information and let us know if you have any questions.

Question Automate adding Category hash to Animations for Sprite Resolver

Discussion in 'Animation' started by jolyn_w, Apr 19, 2023.

  1. jolyn_w


    Apr 19, 2023
    Hi all,

    We are currently looking into upgrading our Unity's version from 2020.3.5f1 to 2022.2.10 version. In the current version that we are using, the Sprite Resolver and Sprite Library are still experimental and to use them in animations, we are to state the category and label hash. However, due to the animation pipeline that we adopted, our animations only have the Label hash of the Sprite Resolver as show below:


    In later versions of Unity, the Sprite Resolver and Sprite Library are no longer experimental and the category and label hash are merged into a property called 'sprite_key'. Our animations are working as intended with category and label hashes when playing the project, but now we want to upgrade the animations to use the sprite_key instead in order to be able to edit them for any tweaks if needed in the future.

    We are planning to use the 2D Animation Asset upgrader to update our sprite libraries and animations to cater to the non-experimental versions of Sprite Library and Sprite Resolver. Based on the documentation, both category and label hashes are required for the upgrader to upgrade the sprite libraries and animations. However, as mentioned above regarding our animation pipeline, we do not have the category hash in our animations.

    Therefore, I have written a script that would add the category hashes to our animations based on the label hash in the animations. However, there are some issues that I faced when writing the automation script:
    • Tried looping through all sprite libraries, storing a dictionary of label hashes and the respective category hash that the label hash will be mapped to. However, we have sprite libraries that indicates sprites that shares the same label, but are classified under different categories (Eg. label_01 - found under Cat_01, Cat_02 of same sprite library / different sprite libraries). The possibility of duplicate labels makes this method harder to proceed on as I am not sure how to differentiate which category to use for the label.

    • Thought of going through the prefab route where we would load a prefab's contents and get the respective gameobjects with the Sprite Resolver components and add them to the animations that the prefab uses. However, we have animations that are in animation overrides that are set during runtime, as well as some animations that are not in any overrides or animators and is replaced during runtime to be played by some gameobjects.
    Will it be possible to get some insights on how to proceed on / any other methods that we could try out? We would like to avoid having to go to every prefab, and manually record the changes to add category hash to all possible animations that the prefab would be using as we have a lot of assets to work with, and there is the possibility of missing out some assets while doing so.

    Hopefully this is not too confusing to understand!
  2. kinorotpirsum


    Dec 14, 2022
    I would also like information on this topic, it would be very easy and useful for me!