Search Unity

Place GUI Label on position of image help!

Discussion in 'Scripting' started by platinumfresh, Aug 23, 2017.

  1. platinumfresh

    platinumfresh

    Joined:
    May 22, 2017
    Posts:
    12
    I'm trying to add a counter to my inventory ex. (you right click on a potion and the number that you have goes down) I'm having trouble placing a label on the gui image itself on my inventory screen.

    the first image is what is looks like now
    the second is where I'd like to add the label
    and the third is where I'd like to have the label follow if moved
    Inventoryex1.JPG Inventoryex2.JPG Inventoryex3.JPG
     
  2. Kiwasi

    Kiwasi

    Joined:
    Dec 5, 2013
    Posts:
    16,860
    This is literally just parent/child stuff. Just set the UI.Text as a child of the UI.Image.
     
  3. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,401
    Don't spam tags. I removed them all since none of them applied to this post.

    --Eric
     
  4. Magiichan

    Magiichan

    Joined:
    Jan 5, 2014
    Posts:
    403
    Are you using the Canvas UI System? If so, generate Text Components and make them children of the item images.
    Every time you update the item count, you should check whether the count is 0, if that's the case, disable the Text Component.
     
  5. platinumfresh

    platinumfresh

    Joined:
    May 22, 2017
    Posts:
    12
    Figured it out, in the code where I draw the inventory I put a if statement that says if the item in the slot is a consumable item then place a gui.label on it and in the code where it decides if I can use the potion or not I added the counter for the stack so when I click a potion the stack number in my inventory updates
     
    Magiichan likes this.
  6. platinumfresh

    platinumfresh

    Joined:
    May 22, 2017
    Posts:
    12
    check the above reply