modify a template item from a data file

Hi there, I want to create a template gameobject that contains lots of sprites and labels. This is intended to be a shop item.

I want to then modify this item from a data file so that the item icon, name, cost etc are set to the shop item.

The reason I want to do this is so I can create one template item that is duplicated and modified for each item. This will make it easier to balance and maintain but I’m not sure how to go about doing it. Someone mentioned looking into XML

What I do for that kind of thing is create an empty object and attach a script to it. Then you make public texture2d’s and drag the sprites onto it, or use a generic list because that also shows up in the editor and is easy to change. You would probably then make it a prefab and instantiate and use the data to modify it. I personally would make one item for each texture, though, and just change things like cost. The other way to do it is to make a class that has name, texture, cost, etc and make sure it isn’t a monobehavior. Then you can make a generic list of class type that you instantiate from the data and add to the list.

Thanks fire7side that’s really helpful. What would be the best method of creating and storing the data though? Would I do something like creat an array of the same class in a scriptable object or something?

Thanks again

That’s about exactly what you’d do.
www.jacobpennock.com/Blog/?p=670

Yeah, or you could use xml or whatever. Check the unity wiki. serializable classes are also pretty cool as unity has some special places for them: