adding classes to arrays

I’ve been working with arrays to get familiar with them and hopefully create an inventory system. I can’t think of a way to create an class and add it to an array. I looked at a script online where the creator made a class in another script and then added it to an array in the main script. i really just want to add a set of information to an array; for example, an object/class with a name, description, and an associated game object.
I know you can add game objects and such to arrays:

var object : Transform;
var arr = new Array();

function Start (){

Something like that. does anyone have any idea how i could add a class to the array?

Here's some example code that uses a test class named FunkyItem.

Like you requested, a FunkyItem object has a name, a description, and a reference to a GameObject.

If you assign a GameObject to the slot named Test Object in the Inspector, the Start function will demonstrate the use of classes and constructors (when you press play).

I just typed this on the fly, so I'm sure there are a few syntax errors. Hope it helps!

/* a test object - set in the Inspector */

var testObject   :  GameObject;

/* how many items to put in the array when the Start function runs */

var arraySize    :  int  =  10;

/* builtin arrays of FunkyItems that can be edited in Inspector
/* note: pressing play will cause the Start function to populate them */

var arrayTwo             :  FunkyItem [];
var useMeInTheInspector  :  FunkyItem [];

/* example class */

class FunkyItem
    var name     :  String;
    var descrip  :  String;
    var gameObj  :  GameObject;

    /* default constructor - takes no arguments */

    function FunkyItem ()
        name     =  "Default Name";
        descrip  =  "Default description";

    /* a constructor that takes 3 arguments and assigns the GameObject */

    function FunkyItem ( n : String, d : String, go : GameObject )
        name     =  n;
        descrip  =  d;
        gameObj  =  go;

function Start ()

    /* a dynamic 'javascript' array that could be used for any object */

    var arrayOne = Array();

    /*  builtin arrays must be initialized           */
    /*  they can be edited in the Inspector          */

    /*  initialize the builtin array declared above  */

    arrayTwo = new FunkyItem [arraySize];

    /* populate dynamic array using the default constructor */

    for ( var i = 0; i < arraySize; i ++ ) {
        var tempItem = new FunkyItem();

    /* populate builtin array using the constructor that takes 3 args */

    for ( var j = 0; j < arraySize; j ++ ) {

        var theName = "Item number " + j;
        var theDesc = "They say " + theName + " is very funky";

        /* create new FunkyItem using the object declared in Inspector */

        var tempItem  =  new FunkyItem(theName, theDesc, testObject);

        arrayTwo[j] = tempItem;

    /* test it */

    for ( var k = 0; k < arraySize; k ++ ) {
        Debug.Log("Array one item " + k + " - " + arrayOne[k].name);
        Debug.Log("Array two item " + k + " - " + arrayTwo[k].name);

    /* how to turn ArrayOne into something you can use in the Inspector */

    useMeInTheInspector  =  arrayOne.ToBuiltin(FunkyItem);

I’m not sure if I understand your problem correctly…
You want that what you posted there, just instead of ‘var object: Transform’ something like ‘var object: MyThing’?
Just make a new .js file and name it ‘MyThing’ and for testing, add the line:

var stuff : 'string';

And then in your original script you should be able to do

var object1 : MyThing;
var object2 : MyThing;
object1.stuff = "hey!";
object2.stuff = "oi...";
var arr = new Array();    

function Start () {

Bonus Info: If you want to be über, try wrapping

class MyThing extends ScriptableObject {  }

around the whole code. [Note: I’m not 100% certain about the syntax/spelling…]
At this point, this doesn’t influence how this class will work in your array.
But ScriptableObject is the intended root-class for all classes that just hold information and are not intended to be attached to a GameObject. [Beware! Trying to add these scripts as Components will cause problems!]
By contrast to the Class MonoBehaviour which is the baseclass for all self-made GameObject-Components.
(All .js files secretly add

class [the name of your .js file here] extends MonoBehaviour {  } 

and wrap your code if nothing else is specified)

Also, if you want to learn more about Arrays you might find this helpful:

Greetz, Ky.