- Home /
Vertical Layout draw order, child appears above parent
Hello everyone! I need to draw a slot image in front of box image and follow its position, easy - place down it in the hierarhy, but i have slot in the object that has vertical layout group. And i dont know why parent appears in front of child? Can anybody help? :) Thanks in advance.
It looks to me like the small skill-box DOES get drawn over the larger box. The frame of the skill-box does look messed up, but I suspect that's a different issue. If I misunderstand, please clarify.
at first i thought he means that the skill is not above or in front of the box in terms of layer sorting but i guess he means the skill placement is not at the middle top of the box.
I mean how can i make box to appear in front of the skill, so you dont see those ugly yellow lines.
Answer by Mehrdad995 · Dec 18, 2016 at 09:00 PM
in order to draw parent above its child you have to follow these steps :
create a material and use the "UI/Default" shader on it.(any shader works but the UI default is almost the one used for UI elements by default so you wont notice any change to your UI image).
assign the material to the parent object.
select the material.
switch the inspector to debug mode.
increase the value of "Custom Render Queue" something above 3000 would be fine.
**Note that as far as i know you can also use an overlay shader without the need to change "Custom Render Queue" value.
**In conclusion I personally advise you not to do so but make both the box(parent) and the skill(child) children of another empty gameobject so you can move them up and down in hierarchy to sort the layers, because using different materials in UI will significantly increase drawcalls!
Answer by Creeper_Math · Dec 18, 2016 at 09:12 PM
On the object you want to be under the other, set it's "order" in the inspector to -1 and it should work...
Another one that may be easier to do is set the "z" position to either a positive or negative value...