Creating item-packages with properties

I actually feel rather stupid asking this, but here goes.

I'm trying to create a whole array of items to be used in my game, but all items have some base properties. I want create one script with the entire list of items. Now comes the hard part: I want to be able to call in this script for a particular item and its property, much like asking gameobject.transform.position.

I realise this sounds vague, so as example: I want to find an item called "Turnip" in this list, and I want to add it to my inventory-screen. So I need to ask from the list the Turnip.associatedIcon, Turnip.SellPrice, Turnip.QuantityInInventory, etc etc.

How would I best go about this?

Use your own class:

class Item {
    var associatedIcon : Texture2D;
    var sellPrice : int;
    var quantityInInventory : int;

Then make a Dictionary where the key is a string:

import System.Collections.Generic;

function Start () {
    var itemList = new Dictionary.<String, Item>();
    itemList["Turnip"] = new Item();
    itemList["Turnip"].sellPrice = 5;

Use a constructor in the class to make it easier to work with.

Alternately, use a standard fixed array (say there are 3 different items):

var itemList = new Item[3];

Set up an enum with the names:

enum ItemName {Turnip, Apple, Bread}

Then you can refer to the entries using the enum:

itemList[ItemName.Turnip] = new Item();
itemList[ItemName.Turnip].sellPrice = 5;

I guess the best way is to launch a function when you are looking for an object.

Assuming Javascript and that 'name = "Turnip"'

   function findObject(name : string){

    for(var obj in ObjectArray){

    if( == name){




    print("You do not have a " + name + "in your inventory");




Does this help?