title: Why when trying to make vertical scroll in editorwindow I'm getting exception InvalidOperationException: Stack empty.?
body: <p>What I'm trying to do is to add automatic vertical scroll when expanding the editorwindow too much to the bottom :</p>
  
  <p>If in the screenshot for example this is the original editorwindow size :</p>
  
  <p><a href="https://i.stack.imgur.com/zTnaH.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zTnaH.jpg" alt="Editor Window original size"></a></p>
  
  <p>When clicking for example the Conversations and collapsing it then I want to make it with a vertical scroll :</p>
  
  <p>I can keep stretching down the window with the mouse but I want to use scroll in that case instead :</p>
  
  <p><a href="https://i.stack.imgur.com/zrodJ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zrodJ.jpg" alt="Editor Window collapsed down stretched with the mouse dragging down"></a></p>
  
  <pre><code>using System.Collections;
  using System.Collections.Generic;
  using UnityEditor;
  using UnityEditorInternal;
  using UnityEngine;
  
  public class ConversationsEditorWindow : EditorWindow
  {
      [MenuItem("Window/Editor Window Test")]
      static void Init()
      {
          // Get existing open window or if none, make a new one:
          ConversationsEditorWindow window = (ConversationsEditorWindow)EditorWindow.GetWindow(typeof(ConversationsEditorWindow));
      }
  
      void OnGUI()
      {
          GameObject sel = Selection.activeGameObject;
          ConversationTrigger targetComp = sel.GetComponent&lt;ConversationTrigger&gt;();
  
          if (targetComp != null)
          {
              EditorGUILayout.BeginVertical();
              var editor = Editor.CreateEditor(targetComp);
              var tar = editor.targets;
              editor.OnInspectorGUI();
              EditorGUILayout.EndScrollView();
              EditorGUILayout.EndVertical();
          }
      }
  }
  </code></pre>
  
  <p>The exception message is a bit long :
  The exception is on line 27 :</p>
  
  <pre><code>EditorGUILayout.EndScrollView();
  </code></pre>
  
  <blockquote>
    <p>InvalidOperationException: Stack empty.
    System.Collections.Stack.Peek () (at :0)
    UnityEngine.GUI.EndScrollView (System.Boolean handleScrollWheel) (at C:/buildslave/unity/build/Modules/IMGUI/GUI.cs:1481)
    UnityEngine.GUILayout.EndScrollView (System.Boolean handleScrollWheel) (at C:/buildslave/unity/build/Modules/IMGUI/GUILayout.cs:387)
    UnityEditor.EditorGUILayout.EndScrollView () (at C:/buildslave/unity/build/Editor/Mono/EditorGUI.cs:9203)
    ConversationsEditorWindow.OnGUI () (at Assets/Editor/ConversationsEditorWindow.cs:27)
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at :0)
    Rethrow as TargetInvocationException: Exception has been thrown by the target of an invocation.
    System.Reflection.MonoMethod.Invoke (System.Object obj, System.Reflection.BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) (at :0)
    System.Reflection.MethodBase.Invoke (System.Object obj, System.Object[] parameters) (at :0)
    UnityEditor.HostView.Invoke (System.String methodName, System.Object obj) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:342)
    UnityEditor.HostView.Invoke (System.String methodName) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:336)
    UnityEditor.HostView.InvokeOnGUI (UnityEngine.Rect onGUIPosition, UnityEngine.Rect viewRect) (at C:/buildslave/unity/build/Editor/Mono/HostView.cs:310)
    UnityEditor.DockArea.DrawView (UnityEngine.Rect viewRect, UnityEngine.Rect dockAreaRect, System.Boolean customBorder, System.Boolean floatingWindow, System.Boolean isBottomTab) (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:361)
    UnityEditor.DockArea.OldOnGUI () (at C:/buildslave/unity/build/Editor/Mono/GUI/DockArea.cs:320)
    UnityEngine.Experimental.UIElements.IMGUIContainer.DoOnGUI (UnityEngine.Event evt, UnityEngine.Matrix4x4 worldTransform, UnityEngine.Rect clippingRect, System.Boolean isComputingLayout) (at C:/buildslave/unity/build/Modules/UIElements/IMGUIContainer.cs:244)
    UnityEngine.GUIUtility:ProcessEvent(Int32, IntPtr)</p>
  </blockquote>