Hi All
I have a GameObject “Button” which includes the sortingGroup Component [RequireComponent(typeof(SortingGroup))] the Button has two child objects Background and Text, I have an editor script which destroys and recreates these two child Objects with the following inspector options
bool “Include text” destroys or creates the text Object accordingly
and Sprite “idle Image” changing the idleImage sprite destroys the background object and recreates it with a newly calculated collider to match the Sprite size and shape
Now All works great but depending on what order you change those two inspector properties sometimes the text appears behind the background, so how do I change the order of the child Objects so the background always appears behind the text, Ive checked the documentation for SortingGroup but cant find any properties of methods which change the child Objects order, unless Im missing something. Whats the best way to do this ?
Thanks ![]()