title: Unity With C# script : Class Data Type Passing Value From Class Data Twice Weird
body: <p>I got a simple Question and weird from passing value to data type class variable.</p>
  
  <p>The code below :</p>
  
  <p>itemDatabase.cs</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  using System.Collections.Generic;
  
  public class itemDatabase : MonoBehaviour {
      public List&lt;item&gt; items = new List&lt;item&gt;();
  
      // Use this for initialization
      void Start () {
          // Add Data To Item List With Class Item
  
          // ------------------------------- Item Corps (Raw - Big Tree) ------------------------------- //
          items.Add (new item ("Lemon", 1, "Honey Lemon", 9, 1020, 75, 158, 0, 1, item.RawTree.BigTree, item.ItemType.Raw, item.ItemProd.Corps, "Corps"));
  
      }
  
  // Update is called once per frame
  void Update () {
  
  }
  </code></pre>
  
  <p>}</p>
  
  <p>Constructor :</p>
  
  <pre><code>using UnityEngine;
  using System.Collections;
  
  // Make Class Item
  public class item {
      public string itemName;
      public int itemID;
      public string itemDesc;
      public string itemIcon;
      public GameObject itemModel;
      public int itemTime;
      public int hightprice;
      public int stdprice;
      public int itemStock;
      public int harvest;
      public RawTree rawTree;
      public ItemType itemType;
      public ItemProd itemProd;
      public int Lvlunlock;
      private string baseName;
  
      public enum ItemType {
          Raw,
          Admirable,
          Valuable
      }
  
      public enum RawTree {
          BigTree,
          SmallTree,
          Field,
          None
      }
  
      public enum ItemProd {
          AnimalBarm,
          Mining,
          Corps,
          Dairy,
          JuiceJamMaker,
          Merchant,
          Kitchen,
          Bakery,
          CraftHouse
      }
  
  public item (string name, int ID, string desc, int harvestx, int time, int stdpricex, int hightpricex, int stock, int Lvlunlockx, RawTree RawTree, ItemType type, ItemProd prod, string folderx) {
      itemName = name;
      itemID = ID;
      itemDesc = desc;
      harvest = harvestx;
      itemTime = time;
      stdprice = stdpricex;
      hightprice = hightpricex;
      itemStock = stock;
      Lvlunlock = Lvlunlockx;
      rawTree = RawTree;
      itemType = type;
      itemProd = prod;
      **// line : 60 
      // itemName contain : "Lemon" // folderx contain : "Corps"**
      this.baseName = folderx + "/"; **// basename is directory source picture**
      itemIcon = this.baseName + itemName;
      Debug.Log ("item name : " + itemName); **// result : "Lemon"**
      Debug.Log ("item icon : " + itemIcon); **// result : "Corps/Lemon/Lemon" Why this appear "Corps/Lemon/Lemon" not "Corps/Lemon" ???? this is a mistake right ??**
      Debug.Log ("this.basename : " + this.baseName); **// result : "Corps/Lemon" why this appear "Corps/Lemon" not "corps/" ???? this is also a mistake right ???**
  }
  </code></pre>
  
  <p>this.baseName is source of directory picture for examples : </p>
  
  <p>this.baseName = "Corps/Lemon". So it from Folder "Corps" file "Lemon".
  this.baseName = folderx + "/"; folderx is input from itemDatabase : items.Add (new item ("Lemon", 1, "Honey Lemon", 9, 1020, 75, 158, 0, 1, item.RawTree.BigTree, item.ItemType.Raw, item.ItemProd.Corps, "Corps")); // "Corps" refer to folderx</p>
  
  <p>//Add Item Method</p>
  
  <pre><code>void AddItem(int ID) {
          for (int i = 0; i &lt; database.items.Count; i++) {
              if(database.items[i].itemID == ID) {
                  itemxs = new item (database.items [i].itemName,
                                    database.items [i].itemID,
                                    database.items [i].itemDesc,
                                    database.items [i].harvest,
                                    database.items [i].itemTime,
                                    database.items [i].stdprice,
                                    database.items [i].hightprice,
                                    database.items [i].itemStock,
                                    database.items [i].Lvlunlock,
                                    database.items [i].rawTree,
                                    database.items [i].itemType,
                                    database.items [i].itemProd,
                                    database.items [i].itemIcon);
                  // Line 80
                  Debug.Log ("Item Icon 1 : " + database.items[i].itemIcon); // result "Corps/Lemon"
                  Debug.Log ("Item Icon 2 : " + itemxs.itemIcon); // result "Corps/Lemon/Lemon";
  
                  CheckInventoryExist(itemxs);
                  break;
              }
          }
      }
  </code></pre>
  
  <p>The problem start from line 60 and line 80 (at Add item method) as you can see i just passing the value from </p>
  
  <pre><code>itemxs = new item (database.items [i].itemName,
                                        database.items [i].itemID,
                                        database.items [i].itemDesc,
                                        database.items [i].harvest,
                                        database.items [i].itemTime,
                                        database.items [i].stdprice,
                                        database.items [i].hightprice,
                                        database.items [i].itemStock,
                                        database.items [i].Lvlunlock,
                                        database.items [i].rawTree,
                                        database.items [i].itemType,
                                        database.items [i].itemProd,
                                        database.items [i].itemIcon);
  </code></pre>
  
  <p>this when i debug got wierd value.</p>
  
  <pre><code>  // Line 80
  Debug.Log ("Item Icon 1 : " + database.items[i].itemIcon); // result "Corps/Lemon"
              Debug.Log ("Item Icon 2 : " + itemxs.itemIcon); // result "Corps/Lemon/Lemon";
  </code></pre>
  
  <p>Any Idea ??</p>
  
  <p>Dennis</p>