Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

Question Moving an element to the top of the hierarchy

Discussion in 'UI Toolkit' started by CoryMaklin, Sep 22, 2021.

  1. CoryMaklin

    CoryMaklin

    Joined:
    Oct 10, 2020
    Posts:
    29
    I'm trying to drag an item. However, BringToFront only brings the element to the front of its siblings.
    I know some tutorials made use of a "ghost" element at the top of the hierarchy. I was wondering if there was a way to move an element up the hierarchy. I don't see a way of setting the element's parent.
     
  2. CoryMaklin

    CoryMaklin

    Joined:
    Oct 10, 2020
    Posts:
    29
    I believe I may have answered my own question. It appears you can do it by getting the root element to call Add and pass the element in question.
     
  3. griendeau_unity

    griendeau_unity

    Unity Technologies

    Joined:
    Aug 25, 2020
    Posts:
    230
    We have BringToFront and its opposite SendToBack if you want to bring it to either end of the children hierarchy.
    We also have PlaceBehind and PlaceInFront, if you know the sibling element that needs to be under/on top.
    Or like you said Add can do the trick, or Insert if you want more control over the position.