Unity With C# script : Class Data Type Passing Value From Class With Data Twice Weird

后端 未结 2 1579
无人及你
无人及你 2021-01-24 11:32

I got a simple Question and weird from passing value to data type class variable.

the code like below :

void AddItem(int ID) {
    for (int i = 0; i <         


        
2条回答
  •  夕颜
    夕颜 (楼主)
    2021-01-24 12:01

    In your constructor:

     this.baseName = folder + "/";  // if folder = "Corps/Lemon" from database.items[i].itemIcon
     itemIcon = this.baseName + itemName; // it will update itemIcon to "Corps/Lemon" + "/" + "Lemon"
    

    Did you get it now??

    You may want to assign itemIcon value directly instead of doing all this.

    Do this in your constructor :

    itemIcon = folder;
    

    Cheers

提交回复
热议问题