title: Unity Inventory stacking not functioning properly
body: <p>I'm a beginner at Unity.</p>
  
  <p>I'm trying to make an inventory system where if you have say 4 wood, it would not take up 4 inventory spaces, only 1 that has a number 4. </p>
  
  <p>When I get 4 wood normally, and open the inventory, it works fine, with the wood icon and the number 4. When I add using the inspector to a public List, it just duplicates the first entry. Here's what I'm talking about. Here's the code:</p>
  
  <pre><code>public void OpenInventory()
  {
  
      inventoryPanel.SetActive(true);
      Dictionary&lt;string, int&gt; stuff = new Dictionary&lt;string, int&gt;();
      stuff = new Dictionary&lt;string, int&gt;();
      //updating inventory slots on screen
      for (int i = 0; i &lt; inv.Count; i++)
      {
          if (!stuff.ContainsKey(inv[i]))
          {
              stuff.Add(inv[i], 1);  
          }
          else
          {
              stuff[inv[i]] = stuff[inv[i]] += 1;
          }
  
      }
  
      for (int i = 0; i &lt; stuff.Count; i++)
      {
          uiSlots[i].GetChild(0).gameObject.GetComponent&lt;Image&gt;().sprite = Resources.Load&lt;Sprite&gt;("Sprites/" + inv[i]) as Sprite;
  
          uiSlots[i].GetChild(1).GetComponent&lt;Text&gt;().text = stuff[inv[i]].ToString();
  
      }
  
  
  }
  </code></pre>
  
  <p>Before I make changes (working fine): </p>
  
  <p><a href="https://i.stack.imgur.com/wo7tM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wo7tM.png" alt="Before I make changes"></a></p>
  
  <p><a href="https://i.stack.imgur.com/i4sy7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/i4sy7.png" alt="still before but the graphical thingy"></a></p>
  
  <p>Now, when I change the inventory in inspector and refresh the inventory screen:</p>
  
  <p><a href="https://i.stack.imgur.com/BM8GN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BM8GN.png" alt="after I make changes"></a></p>
  
  <p><a href="https://i.stack.imgur.com/r3Zkn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r3Zkn.png" alt="still after I make changes"></a></p>
  
  <p>I genuinely have no idea what is going on, especially because if I do the same thing again, nothing changes. </p>