How to include custom art/styles in editor scripts

Hi

I have seen other editor scripts use custom styles (i.e icons on buttons and such). How can I include custom art in my editor scripts without having a variable in the inspector which points to a GUISkin?

Thanks!

For editor scripts, the code must be in an Editor/ folder, so place your skin in, say, the Editor/Skin folder (you'll need the exact path for the call, below).

In your editor script, you can do something like this:

public class MyEditorWindow : EditorWindow
{
  private static GUISkin editorSkin = null;

  void OnGUI()
  {
    if( editorSkin == null )
    {
      editorSkin = (GUISkin)(Resources.LoadAssetAtPath("Assets/Editor/Skin/MyEditorSkin.guiskin", typeof(GUISkin)));
    }
    GUI.skin = editorSkin;

    // go nuts
  }
}