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

心已入冬 提交于 2019-12-02 03:06:45

In item constructor you are doing it:

this.baseName = folder + "/";
itemIcon = this.baseName + itemName;

where folder == Corps and this.baseName == "Corps/Lemon/" and itemName == "Lemon" so you have exactly what you should get.

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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!