x


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!

more ▼

asked Dec 21 '09 at 10:10 AM

TowerOfBricks gravatar image

TowerOfBricks
3.2k 17 25 50

(comments are locked)
10|3000 characters needed characters left

1 answer: sort voted first

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
  }
}
more ▼

answered Dec 31 '09 at 05:17 PM

Molix gravatar image

Molix
4.8k 15 27 66

Thanks, I didn't thought it was that easy.

Jan 04 '10 at 08:55 PM TowerOfBricks

You can also procedurally create GUIStyles.

Dec 09 '10 at 05:50 PM yoyo

A ton of thanks!

Dec 17 '10 at 12:54 AM Statement ♦♦
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x3678
x1667
x348
x69
x1

asked: Dec 21 '09 at 10:10 AM

Seen: 2035 times

Last Updated: Apr 04 '11 at 07:48 AM