Search Unity

  1. Good news ✨ We have more Unite Now videos available for you to watch on-demand! Come check them out and ask our experts any questions!
    Dismiss Notice

Select an item from my inventory

Discussion in 'UI Toolkit' started by Jihaysse, May 2, 2020.

  1. Jihaysse

    Jihaysse

    Joined:
    Mar 29, 2020
    Posts:
    8
    Hello everyone,
    I've ran into an issue and hope you can help me.
    i've been making this function to update my inventory:
    Code (CSharp):
    1.  
    2. public class CallMenu : MonoBehaviour
    3.  
    4.     public GameObject[] itemButton;                 // INVENTORY
    5.     public Text[] quantityText;
    6.     public RawImage[] itemImage;
    7.     public Text descriptionName, descriptionText;
    8.     public RawImage descriptionImage;
    9.  
    10. public void UpdateInventory()
    11.     {
    12.         List<IInventoryShortcut> items = new List<IInventoryShortcut>();
    13.    
    14.  
    15.         for (int i = 0; i < itemButton.Length; i++)
    16.         {
    17.             itemButton[i].SetActive(false);
    18.  
    19.             if( i < items.Count)
    20.             {
    21.                 itemButton[i].SetActive(true);
    22.                 itemImage[i].texture = items[i].GetIcon();
    23.                 quantityText[i].text = items[i].Quantity.ToString();
    24.                 descriptionName.text = items[i].GetName();
    25.                 descriptionText.text = items[i].GetDescription();
    26.                 descriptionImage.texture = items[i].GetIcon();
    27.             }
    28.        
    29.  
    30.         }
    31.     }
    It works well to display and update my inventory, but now I want to display the SELECTED ITEM (when clicking on one of the itemButton) data into the descriptionName, descriptionText and descriptionImage. Any idea on what I should replace "items.Get()" with?

    Thank you for your help!
    Jihaysse
     
  2. DonLoquacious

    DonLoquacious

    Joined:
    Feb 24, 2013
    Posts:
    1,667
    This looks like a UGUI problem, you might be better off posting in the UGUI forum for support.
     
unityunity