[HELP] Change rendering order of buttons

Hey!, I’m creating an inventory which highly relies on buttons. The problem is that the slots render over the items so I need to change the rendering order of them. I know that this have been posted quite many times but I still haven’t found a solution. :face_with_spiral_eyes:

If two objects are siblings in the hierarchy, the one listed second will be rendered on top of the one above it. I know that sounds confusing, but if you think of the hierarchy from top to bottom as draw order, it makes more sense.

There are ways to override this behavior with layer indexing and whatnot, but changing the order in the hierarchy is the simplest way, and I’ve never needed to do anything else.

1 Like

I have thought of that the problem is that it doesn’t work. This is how the hierarchy is:

Slot 1

  • Item
    Slot 2
    Slot 3

Slot 2 therefor renders over the item

Can you post a screenshot? I’m not sure I’m understanding what the problem is. As in, why would Slot 2 be over top of Slot 1 in the first place?

1 Like

This is the hiercary: http://imgur.com/a/DUJbj I have a inventory with slots and one of them have a item. The item renders under most of the slots.

Haha, I understand that part. I meant a screenshot of where it’s overlapping, sorry. Should have been more clear.

1 Like

http://imgur.com/a/RKQqY Here you can see that the item is behind the slot.

Okay, so let’s back up a second.

You have a number of slots:

  • Slot 1 1
  • Slot 1 2
  • Slot 1 3
  • Slot 1 4
  • etc

My understanding is that these slots are siblings of each other, arranged either horizontally or vertically. Let’s assume for our discussion that “Slot 1 1” is on the far left, with each following slot positioned in line to the right.

If the item is a child of “Slot 1 1”, it will render on top of the image for the slot itself. “Slot 1 2” would technically render on top of both “Slot 1 1” and its child item, but it shouldn’t matter because that slot shouldn’t overlap “Slot 1 1”, right?

So if the problem you’re showing in your hilariously-close-cropped screenshot is that “Item” is rendering behind “Slot 1 1”, then I have to assume you’ve messed with those layer rendering orders I mentioned before, because what you’re seeing is not the default behavior. I don’t have my personal computer with me to be able to test and show you an example, but maybe someone else can chime in and confirm.

1 Like

The item renders behind all slots except Slot 1 1(the parent slot), so 1 2, 1 3 etc. The rest is correct

But shouldn’t the slots not be overlapping each other? So if it’s behind another slot, it shouldn’t matter, since it’s not part of those slots.

I think I’m missing the fundamental piece in what your overall UI looks like and what you’re trying to do here.

1 Like

The problem is NOT the slots, it’s the ITEM that renderes behind which overlaps when moving it between slots.

Gotcha. I think what you want to do there, then is to unparent the item from the slot when moving (ensuring it’s at an appropriate position in the hierarchy to render over ALL slots) and then re-parent it to the appropriate slot when dragging ends.

1 Like

Thanks, will try that. Sorry for being so unclear :frowning:

Not a problem! Let me know how it works out!

1 Like

Have tested it now and it workes great! Thanks for all your help!

1 Like

Awesome! Happy to help!

2 Likes