Search Unity

  1. If you have experience with import & exporting custom (.unitypackage) packages, please help complete a survey (open until May 15, 2024).
    Dismiss Notice
  2. Unity 6 Preview is now available. To find out what's new, have a look at our Unity 6 Preview blog post.
    Dismiss Notice

How to put the text over my label? Unity 2020.2.1f1

Discussion in 'Getting Started' started by kristosaber, Feb 26, 2021.

  1. kristosaber

    kristosaber

    Joined:
    Jan 20, 2021
    Posts:
    33
    Hi,

    May I ask how do I put my text over my label? It is as seen in the image below is below the label.
    Currently, the order in layer for my label is set to 0. I can't find the one for my text field.
    Also both are in Layer - UI.

    Thank you
    text.jpg
     
  2. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    With UI objects, the layering is controlled by the order of the UI objects in the scene hierarchy. So in your Hierarchy window, grab the Text and drag it down below the Image (which I guess is what you're calling the label).
     
    kristosaber and Schneider21 like this.
  3. kristosaber

    kristosaber

    Joined:
    Jan 20, 2021
    Posts:
    33

    Hi,

    I have done what you suggested. Please see below.
    Just to let you know the label I mentioned is the "Enemy Battlehud".
    As you suggested, which I have actually done it, to drag down the text below the label.

    hierarchy1.JPG

    Just in case, you are wondering, all of the label, text are on UI Layer.
    hierarchy3.JPG


    But they still appear below my label.
    hierarchy2.JPG

    Thank you for your patience and guidance
     
  4. kristosaber

    kristosaber

    Joined:
    Jan 20, 2021
    Posts:
    33
    Now, that's strange.... I decided to reset my label's Transform position by right click and reset. Now everything fits ontop of my label. Although I have to resize my label as it becomes very small.

    Hmm... although I managed to solve my problem, I still didn't learn why without resetting my Rect Transform, I can't move my text above my label.

    Thanks for your help JoeStrout.
     
    Last edited: Feb 26, 2021
  5. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    I don't see that you did do it... you have LevelText below (i.e. on top of) NameText, but those are both Texts, right? What is the label image? If it's HPPanel, or something within it, then in your screen shot that is still below both texts (and therefore drawn on top).

    As for resetting the transform, we'd have to see what value it had before to know why it was misbehaving (if it's not just a matter of having them ordered incorrectly in the hierarchy).
     
  6. kristosaber

    kristosaber

    Joined:
    Jan 20, 2021
    Posts:
    33
    Hi JoeStrout,

    As mentioned in my previous post. The Label which I mentioned was the "Enemy Battlehud". I have moved the "NameText" and "LevelText" below the "Enemy Battlehud" label.

    Unfortunately, I didn't manage to capture the value below I reset it. Probably I will do it next time if I encounter this issue again. Thank you.
     
  7. JoeStrout

    JoeStrout

    Joined:
    Jan 14, 2011
    Posts:
    9,859
    Ah, no. You moved NameText and LevelText inside Enemy Battlehud. That actually works too (as you found), but it's not necessary and is not what I was suggesting. I was suggesting you move them below the Image, at the same level of the hierarchy, just further down in the list.

    EDIT: The other thing to possibly consider is the z position of the UI elements. Normally in UI this is always zero. But it's all still technically 3D, so if something here had a nonzero z, that could cause confusion.
     
    kristosaber and Schneider21 like this.
  8. kristosaber

    kristosaber

    Joined:
    Jan 20, 2021
    Posts:
    33
    Noted. I was thinking since i'm doing 2D, there shouldn't be a Z problem. Thanks again!