Skip to main content
elaboration
Source Link

Decided to manipulate hierarchy order after all and it's working pretty well.

I added

for (int i = 0; i < numRows; i++)
{
    inventoryRows[i].transform.SetSiblingIndex(i);
}

to a slot manager script to remove the random ordering upon pressing play, and used transform.SetAsLastSibling()

Then, in my DragHandler script when dragging begins, I added the following to OnBeginDrag()

slotStartingSiblingIndex = transform.parent.GetSiblingIndex();
rowStartingSiblingIndex = transform.parent.parent.GetSiblingIndex();
transform.parent.SetAsLastSibling();
transform.parent.parent.SetAsLastSibling();

and the following to OnEndDrag()

transform.parent.SetSiblingIndex(slotStartingSiblingIndex);
transform.parent.parent.SetSiblingIndex(rowStartingSiblingIndex);

This gives pretty good control of hierarchy order, and thus, of rendering layers.

Decided to manipulate hierarchy order after all and it's working pretty well.

I added

for (int i = 0; i < numRows; i++)
{
    inventoryRows[i].transform.SetSiblingIndex(i);
}

to a slot manager script to remove the random ordering upon pressing play, and used transform.SetAsLastSibling() in my DragHandler script when dragging begins.

Decided to manipulate hierarchy order after all and it's working pretty well.

I added

for (int i = 0; i < numRows; i++)
{
    inventoryRows[i].transform.SetSiblingIndex(i);
}

to a slot manager script to remove the random ordering upon pressing play.

Then, in my DragHandler script, I added the following to OnBeginDrag()

slotStartingSiblingIndex = transform.parent.GetSiblingIndex();
rowStartingSiblingIndex = transform.parent.parent.GetSiblingIndex();
transform.parent.SetAsLastSibling();
transform.parent.parent.SetAsLastSibling();

and the following to OnEndDrag()

transform.parent.SetSiblingIndex(slotStartingSiblingIndex);
transform.parent.parent.SetSiblingIndex(rowStartingSiblingIndex);

This gives pretty good control of hierarchy order, and thus, of rendering layers.

Source Link

Decided to manipulate hierarchy order after all and it's working pretty well.

I added

for (int i = 0; i < numRows; i++)
{
    inventoryRows[i].transform.SetSiblingIndex(i);
}

to a slot manager script to remove the random ordering upon pressing play, and used transform.SetAsLastSibling() in my DragHandler script when dragging begins.