Forum rules - please read before posting.

Inventory - Separate Text element for item Name and Yield

When you create an Inventory Menu using Unity UI and selecting Display type: Icon and text, both the item label (Name) and item yield are populated in the the same Text element in the UI button:
Item Name (99)

Is there a way to have the Item name and yield number appear in separate labels for UI design purposes?

Thanks!

Comments

  • This is with Unity UI?

    You could use scripting to extract the yield/count value for a given UI slot, for display in a custom Text box, but the UI-linked Button will still display it in brackets. I'll look into how this could be made optional.

    Extraction code:

    using UnityEngine;
    using UnityEngine.UI;
    using AC;
    
    public class ShowItemCount : MonoBehaviour
    {
    
        public string menuName = "Inventory";
        public string elementName = "InventoryBox";
        public Text[] yieldTexts;
    
        MenuInventoryBox inventoryBox;
    
    
        private void Start ()
        {
            inventoryBox = PlayerMenus.GetElementWithName (menuName, elementName) as MenuInventoryBox;  
        }
    
        private void Update ()
        {
            for (int i=0; i<yieldTexts.Length; i++)
            {
                int count = inventoryBox.GetItem (i).count;
                yieldTexts[i].text = (count > 0) ? count.ToString () : string.Empty;
            }
        }
    
    }
    
  • Chris, this would still be a great thing! Any news on when this will be implemented in AC?

  • Using a custom script as above is still the best option, since how/where exactly you display such text is going to vary between projects.

Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Welcome to the official forum for Adventure Creator.