Using GUIStyle on an Editor Script

Hi every one, a got this little problem:

In the Editor Script:

var scroll : Vector2;

function OnInspectorGUI () {
    scroll = EditorGUILayout.BeginScrollView(scroll, GUIStyle.box, GUILayout.MinHeigth(100));
    // Some Content.
    EditorGUILayout.EndScrollView();

I have tried many ways to draw the scroll view style but I only got this issue:

NullReferenceException: Object reference not set to an instance of an object
UnityEngine.GUILayoutEntry.ApplyOptions (UnityEngine.GUILayoutOption[] options).

I already read the unity manual, and they said it’s possible, this are the options:

BeginScrollView (scrollPosition : Vector2, alwaysShowHorizontal : boolean, alwaysShowVertical : boolean, horizontalScrollbar : GUIStyle, verticalScrollbar : GUIStyle, background : GUIStyle, params options : GUILayoutOption[]) : Vector2.

If any one can help me to understood this, that will be appreciated.
Thanks in advance.

GUIStyle does not have a member “box”, but that actually isn’t the immediate problem. You should look into EditorStyles for more info on styles in the Editor. Also, you can use a GUISkin in your editor as well if you require a lot of skinning!

Your immediate problem is that your last parameter needs to be an array of GUILayoutOption:

var scroll : Vector2;
function OnInspectorGUI () {
scroll = EditorGUILayout.BeginScrollView(scroll, new GUILayoutOption[1]{GUILayout.MinHeight(100)});
// Some Content.
EditorGUILayout.EndScrollView();

Hope that helps.

==

Sorry for the delay, but according to some tests carried out, certain options can be used to modify the view in the inspector using the default guiskin.

Like this:

var numbers : int;

// On the GUI function in editor script.
numbers = EditorGUILayout.IntField("Value", numbers, "box", GUILayout.MinWidth(100));

This will show an IntField with “box” style.