Allocating GUIStyle[] thru code

Hi,

A little stuck here…The reason that I cannot simply assign values in the inspector before run time is because I don’t quite know the length that I want to allocate styles for.

public GUIStyle[] myStyle;

for (int sIndex = 0; sIndex < getNames.myNames[tmpIndex].Length; sIndex++)
{
    myStyle[sIndex] = new GUIStyle(); //RunTimeError
    myStyle[sIndex].name = getNames.myNames[tmpIndex][sIndex];
}

The reason that I need a GUIStyle array is because I have another array of strings and the colors of which need to be controlled, I click on them and they change colors - I have that understood, the tmp variable should indicate that.

I am getting run time errors and I do not know why probably because of lack of sleep =)

The references to the other scripts are valid.

I can easily assign a large index value of the ‘myStyle’ GUIStyle array varaible in the inspector, but I’d like to be exact.