- Home /
Is there a way to adjust canvas z-ordering while using Alphabetical Sort in the Hierarchy?
I'm fairly new to using the Canvas. I do like the readability/consistency that Alphabetical Sorting gives but when I need to manually adjust sprite z-order of Canvas objects I'm not able to. Clearly it would be silly to allow resorting while in Alphabetical since it would break the rule.
Is there some other way (in the editor/inspector) to adjust Canvas sorting aside from the hierarchy that I'm overlooking?
Not that I'm aware of, but the Hierarchy view does have a search function that may be useful...?
I'm not really looking to search the hierarchy though. Looking for some way to manipulate Canvas objects (which use hierarchy transform order to imply zorder/layering) But when in Alphabetical Sort mode, you're unable to move hierarchy objects around for obvious reasons.
Right, I generally don't use alphabetic for that reason, I just organize my hierarchy into empty gameobject containers, so it's all sorted. $$anonymous$$aybe if you explain the reason you need to use alphabetic, we can suggest a workaround?
Answer by brunocoimbra · May 04, 2016 at 08:06 PM
Just click with the right mouse button on the object's Rect Transform that you want to adjust the order and there will be the options "Move to Back" and "Move to Front".
Beautiful. I hadn't seen that right click option before. You'd think they'd add that to the right click menu when right-clicking in the hierarchy too.
Thanks!
Does it really do what you want if the parent rect transform have a GridLayout or other kind or order dependant layout?
Wow thanks, I was looking for this option for ages!
I wonder why it's hidden like that, almost as hard to find as an easter egg...? It's such an important feature!
That doesn't seem to work at all in a way that is independent from the order in the hierarchy - that was requested in the question. When i click "move to front" it actually moves the object inside the hierarchy.
Answer by coolraiman · May 04, 2016 at 08:12 PM
you should avoid the Alphabetical Sorting
if you order and name your stuff well, your hierarchy will be even more cleaner.
also think of canvas as some sort of html. a child will be over its parent. Group your canvas element into well named empty parent. parent dont have to be empty, you can give them image for backgrounds since they will always be drawn behind its child
Then if you want an object to be drawn over an other and they are sibling you can just play with the sibling index
example:
Transform object1;
Transform object2;
object2.SetSiblingIndex(object1.GetSiblingIndex());
now object 1 will be drawn over object2 Also a child is always drawn over his parents.
for sibling, the first element is in the bottom and the last sibling is on top.
Yea, I do like the consistency of alphabetical, but properly/well organized hierarchies are great. Sometimes hard to enforce though across many $$anonymous$$ms/projects.