Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

How to synchronize Sorting Layers between two projects?

Discussion in 'Editor & General Support' started by RoboM, Mar 17, 2021.

  1. RoboM

    RoboM

    Joined:
    Feb 6, 2018
    Posts:
    9
    I have two Unity projects - the main one with the game, and the other for content loaded at runtime via Addressables. I recreated the main projects Sorting Layers in the second one, so that they are in the same order and named the same. When I load sprite renderers that were set up in the second project in the main one, they have <unknown layer> set as the Sorting Layer. I'm guessing that the IDs mentioned here https://docs.unity3d.com/ScriptReference/Renderer-sortingLayerID.html don't match up between the projects. Is there any way I can force them to match?
     
  2. Kurt-Dekker

    Kurt-Dekker

    Joined:
    Mar 16, 2013
    Posts:
    36,336
    I've never been able to figure this out smoothly. It's annoying. I always just make a "SortingLayerInjection" script that has a string name field and jams it into the renderer at Awake() or Start() but it doesn't really help you at editor time. It's messy.

    I suppose you COULD copy it over forcibly by hand-editing the TagManager.asset. But the prefab where it is used also tracks the index, so that would have to match:

    NOTE: due to 32-bit 2's complement, the value
    -336567667
    is equal to
    3958399629
    , the ID for
    slayer1


    Screen Shot 2021-03-17 at 9.31.45 AM.png

    The actual usage of such a layer (in this case
    slayer1
    ):

    Screen Shot 2021-03-17 at 9.31.49 AM.png
     
    Last edited: Mar 17, 2021
    RoboM likes this.