- Home /
UI Bring to front without modifying hierarchy
I'm trying to create a radial selector using toggle and a radial layout group. It works great, except when there's overlap. I want to bring the toggle to the front when I hover over the overlapping icons, however, both ways I've discovered that can do this have flaws:
1) change the hierarchy so the toggle is the last object in the parent - this won't do, since changing the order will also change the position of the toggle, so when you hover, all the objects will suddenly rearrange themselves on screen due to the layout group
2) add a canvas component with an overriding sorting order. This almost worked, but when I apply it, the textures are on a different canvas from the toggle, so it never triggers the toggle onValueChanged.
Additionally, all these toggles are set up at runtime dynamically, so manually setting up a workaround seems impossible. I feel like I'm missing a critical sort order function here, whether Unity is missing it, or I can't find it.
Appreciate any help! Thanks!!
Answer by Elaixzar2 · Dec 11, 2020 at 02:31 AM
So I got it to work, but it feels a bit hacky.
On the radial layout group, instead of setting the position on the circle by the index in the hierarchy, I had to add a component script to each object in the layout group specifying the index for that component. When the layout group updates, it looks if it has an order script attached and sets the position based on that order index, instead of the hierarchy index.
By doing this, I can then reorder the children inside the radial group and the order will then only affect the draw order, not the radial position.
Talk about a pain in the butt. I feel like that should be a built in option.
Your answer
Follow this Question
Related Questions
How to achieve this desired render order with the new 4.6 UI? 2 Answers
4.6 UI sort order in fornt of IMGUI/OnGUI possible? 2 Answers
uGui image element doesn't render 0 Answers
How to create hierarchy menu such as unity hierarchy tab. 0 Answers
What sets Canvas.renderOrder and why would it not respect the sorting order? 0 Answers