Reputation: 3037
I have noticed that in a canvas the elements are drawn from top to bottom so the image above is covered by the image below. The problem is that I want an ui image that is not the last sibling of the canvas to stay on top of all the others. How can I do?
Upvotes: 2
Views: 11846
Reputation: 381
I would do an edit on Ethan's answer but seems the edit queue is filled so I'm writing it here.
The CanvasGroup solutio does not work. Your other choice aside for changing the sibling index (hierarchy position) is to create a new Canvas, and have it override it's parent canvas's sorting order and add some offset to the new canvas's sorting order. Here's how you'd do it by hand in inspector:
I've also created this simple script/component that does the job dynamically
:
Upvotes: 0
Reputation: 2399
I think you can try two ways.
First.
Use Transform.SetAsFirstSibling()
to put the UI Component on top
Second.
Use CanvasGroup.sortingOrder
to help your UI Component grouping.
Ref
http://docs.unity3d.com/Manual/class-CanvasGroup.html
http://docs.unity3d.com/ScriptReference/Transform.html
Upvotes: 3
Reputation: 3049
there are couple of functions you can use for setting orders
Transform.SetAsFirstSibling
Transform.SetAsLastSibling
Transform.SetSiblingIndex
Upvotes: 1