- Home /
Cannot Set Sorting Layer Name in Nested Canvas Prefab
We have a nested Canvas Prefab (meaning, a canvas within another canvas) that needs to have a sorting layer. When the prefab is in the scene, we are able to set the sorting layer. However when we are in prefab mode, the sorting layer drop-down disappears. We noticed that the sorting layer drop-down somehow reappears if we: 1. Deactivate the prefab 2. Add a new component
We tried creating a custom editor script that sets the sorting layer name on the canvas. But it only works in the scene and not in the prefab view.
Debug.Log(nextSortingLayerName); // prints new sorting layer
canvas.sortingLayerName = nextSortingLayerName;
Debug.Log(canvas.sortingLayerName); // sorting layer has not changed
Here's a gif: https://media.giphy.com/media/gIqbFffhGGZVD8D1KT/source.mov
Sorry for commenting on an old post, but I'd like to echo that this is still happening. Except for us it's happening within the scene hierarchy too. We've been using a utility script to change the sorting layer at runtime. Is there some secret condition that needs to be satisfied for the sorting layer option to appear consistently? Unity v2018.4.19
Your answer
Follow this Question
Related Questions
Is there a way to restrict layering within a gameobject? 0 Answers
UI object drawing order is different between Unity Editor and Standalone version 1 Answer
How to set the UI Text position to be relative to his "grandfather" prefab 0 Answers
Problem with a prefab, need help 0 Answers
Disabling Canvas Prefab only turns off prefab, not in scene canvas 1 Answer