Canvas. How to make one canvas element appear on top of the rest?

My inventory is divided into blocks. The middle block is the inventory slots. The block on the side is the character doll.

In the middle block, I did it through the code.

transfer.parent.SetAsLastSibling();

When I pass a canvas element through another block, this code doesn’t work of course. Is there an easy way to solve this problem through code? Or is it better to redo the inventory architecture?

Blue sword is the cursor.

I solved the problem. Raised the sword in the hierarchy by several points.

transfer.SetParent(transfer.parent.gameObject.transform.parent.gameObject.transform.parent.gameObject.transform.parent);

You can set the Canvas sort order in its inspector and make sure what you want on top to have a higher value than what you want to be behind it :slight_smile:

1 Like

I read on the Internet and it turned out that few people know about this secret technique. The “Override Sorting” variable is responsible for this. Thanks.
Now I probably will not redo it, but in the future it will come in handy.