- Home /
UI Layering Problem!
High im trying to get my object "Special Glow" to render underneath the 3 "special" objects, but when i click play, it moves the Special Glow to the very front, on top of the other UI objects.
Are you doing anything with these game objects in code?
yes this is the code for the objects this is on awake: specialGlow = GameObject.Find ("Special Glow"); special1 = GameObject.Find ("Special 1"); special2 = GameObject.Find ("Special 2"); special3 = GameObject.Find ("Special 3");
this is on Start: specialGlow.SetActive (false); special1.SetActive (false); special2.SetActive (false); special3.SetActive (false);
and this is a long if statement in update: if(specialNmb >= 1) { special1.SetActive (true); } else { special1.SetActive (false); }
if(specialNmb >= 2)
{
special2.SetActive (true);
}
else
{
special2.SetActive (false);
}
if(specialNmb == 3)
{
special3.SetActive (true);
StartCoroutine(Special3());
}
else
{
special3.SetActive (false);
}
Answer by trollanator5729 · Mar 07, 2021 at 10:32 PM
for anyone that comes across this, use a little setting called "Sort order" inside the canvas component to set the Layering of UI elements.
I've never used the Sort Order setting. Is this how it works, by rearranging the children in the way the OP showed?
Answer by SummitJain · Nov 25, 2015 at 12:00 PM
Easy to solve issue.
The Canvas UI renders based on the child object hierarchy. Just select the object and put it outside SpecialBar gameobject and make it directly a child object as its just a background. Make sure that the image is behind the layer of the specialBar. this should immediately fix the issue.
Alternate way:
Just make sure that the SpecialBar object is the last in the heirarchy. Its calling before your menu, score and death Ui objects in Canvas.
Hope this helps. Cheers! Sumit
But it looks to me like the hierarchy order is set up to render the glow beneath the other objects. Can you explain why the hierarchy order is changing when they press Play?
Yes this would work.. but the object needs to be parented to the Special Glow, because it uses animation
@SummitJain ok im trying to do your first suggestion.. but how do i make it directly a child Object??
They mean a direct child of the Canvas, at the same level as Special Bar. Click on it in the hierarchy , drag it up and drop it into the Canvas just above Special Bar.
It should work. But then, as far as I can see, what You've already got should work too. I'm still puzzled as to how the order could be getting changed when you press Play, it doesn't look like you're creating new objects or changing their parenting in code, which are the only potential causes I can think of.
yeah :P well poo.. i will figure out something tho!!
Your answer
Follow this Question
Related Questions
How to move UI Image under the other UI elements? 3 Answers
Canvas UI Priority layers 1 Answer
UI Enabled not working? 1 Answer
Light Raw Image in UI 0 Answers
Detect Input type by checking if ANY key on keyboardd/joypad is pressed 1 Answer