Canvas Sort Order only taking effect upon being edited

What I currently have is the following:

When I click the Computer, I have a prefab instantiated, it’s parent set to a “Window Container”, and all it’s variables updated.

However, even though the sort order is correct, the Text UI component does not render on top.

If I edit the sort order on the component though, changing the value then changing it back, (e.g the value is 2, change to 1 then back to 2), the component works as expected.


The github link for the project is Here if you want to try and recreate this.

Why do you have a Canvas on your Text object?!? That is a very bizarre thing to do.

The standard layout is: you have just one Canvas in your scene. Within that, you have a hierarchy of things with RectTransforms and CanvasRenderer components (such as, for example, Text objects). The drawing order depends on the transform hierarchy. SortOrder has nothing to do with it.

There are occasionally use cases for more than one Canvas in a scene, and then the canvas SortOrder comes into play. But from what you’ve shown here, I don’t think that applies (and I can’t think of any reason why you would have a Canvas component on something like a Text).

The reason why is because I want the text layer to draw on top of its parent, with the each child drawing upon their parent respectively.

From what I’ve read, Unity draws the hierarchy with parent on top of child, rendering my whole idea impossible.

The reason each component has a canvas is due to the ability of the sort order which lets me perform what I want.

That’s a reason to arrange your UI objects in a hierarchy within a Canvas. It is not a reason to add a Canvas component to every UI object.

You read incorrectly. :slight_smile: Unity draws the hierarchy exactly as you want.

No. That’s just going to make a mess of things. An object cannot usefully be both a CanvasRenderer (i.e., something that renders within a canvas) and, itself, a Canvas (something that contains CanvasRenderers).

I think maybe going back over some of these tutorials will save you time in the long run.

Good luck with your project!

Thanks for that info, that changes a lot of things for me. I’ll give it a shot.:slight_smile:


That works perfectly now! Thanks :smile:

1 Like