Accessing GUISkin.CustomStyles?

So what kind of mongrel object is GUISkin.CustomStyles anyway?

In the inspector, it acts like an array of GUIStyles, and I can successfully refer to a custom style element by saying:

var mySkin : GUISkin;
var theStyle : GUIStyle = mySkin.customStyles[1];

BUT

mySkin.customStyles.length

throws the following error:

Assets/Editor/CustomSkinInfo.cs(17) error: UnityEngine.GUIStyle[ ]' does not contain a definition for length’

I want to know this because I was writing a little editor script that would list all the Custom Styles by name and index number so it would be easier to twirl down the specific one I want.

But there doesn’t seem to be a way to recover how many styles there are.

Try with an upper case L

Thanks, Joachim. Sorry to betray my lack of familiarity with C#.

Here’s the script in case anyone else would find it useful:

using UnityEngine;
using UnityEditor;
using System.Collections;

public class CustomSkinInfo : ScriptableObject
{   
    [MenuItem ("Custom/List Custom GUI Styles")]
    static void ShowStyles()
    {
        string output = "";
		GUISkin theSkin = (GUISkin) Selection.activeObject;
		for (int i=0; i<theSkin.customStyles.Length; i++)        
        {
            output += i + ": " + theSkin.customStyles[i].name + "\n";
        }

        EditorUtility.DisplayDialog("Custom Style Names by Index", output, "OK", "");
    }
    
    
}

================
But how can i create and apply a custom style in java scipts?