void OnGUI() { if (Event.current.type == EventType.Layout && m_PanelView == null) { Close(); return; } m_PanelView.EditorWindow = this; m_PanelView.DrawAsWindow = true; var hasHelp = m_PanelView.HelpButtonAction != null; var hasSettings = m_PanelView.SettingsButtonFunc?.Invoke() != null; using (var outerArea = new EditorGUILayout.VerticalScope(GUIStyle.none)) { // Used Begin & End instead of scope for optional scrolling if (m_PanelView.PanelPopoutCanScroll) { m_ScrollView = EditorGUILayout.BeginScrollView(m_ScrollView, GUIStyle.none); } using (var innerArea = new EditorGUILayout.VerticalScope(GUIStyle.none)) { if (Event.current.type == EventType.Repaint && m_PanelView.PanelPopoutCanScroll) { m_VerticalScrollActive = outerArea.rect.height <= innerArea.rect.height; m_HorizontalScrollActive = outerArea.rect.width <= innerArea.rect.width; } if (hasHelp || hasSettings) { EditorGUIUtils.DrawFoldoutUI( true, false, string.Empty, GUIStyle.none, GUIStyle.none, m_PanelView.OnGUI, null, m_PanelView.HelpButtonAction, m_PanelView.SettingsButtonFunc, null); } else { m_PanelView.OnGUI(); } m_PanelView.ScrollingVertical = m_VerticalScrollActive; m_PanelView.ScrollingHorizontal = m_HorizontalScrollActive; } if (m_PanelView.PanelPopoutCanScroll) { EditorGUILayout.EndScrollView(); } } }
void OnGUI() { if (!MARSEntitlements.instance.EntitlementsCheckGUI(position.width)) { return; } if (EditorApplication.isPlayingOrWillChangePlaymode && !Application.isPlaying) { GUIUtility.ExitGUI(); } var headerToggle = MarsEditorGUI.Styles.HeaderToggle; var headerLabel = MarsEditorGUI.Styles.HeaderLabel; using (var outerArea = new EditorGUILayout.VerticalScope(GUIStyle.none)) { using (var scrollView = new EditorGUILayout.ScrollViewScope(m_ScrollView)) { using (var innerArea = new EditorGUILayout.VerticalScope(GUIStyle.none)) { if (Event.current.type == EventType.Repaint) { m_VerticalScrollActive = outerArea.rect.height <= innerArea.rect.height; m_HorizontalScrollActive = outerArea.rect.width <= innerArea.rect.width; } EditorGUIUtils.DrawSplitter(); foreach (var panelView in m_PanelViews) { var drawAsWindow = DrawAsWindow(panelView); var panelExpanded = panelView.PanelExpanded; panelExpanded = EditorGUIUtils.DrawFoldoutUI( panelExpanded && !drawAsWindow, !drawAsWindow, panelView.PanelLabel, headerToggle, headerLabel, panelView.OnGUI, panelView.RecordFoldoutAnalyticsEvent, panelView.HelpButtonAction, panelView.SettingsButtonFunc, panelView.TabMenuFunc); // Don't want to set panel these values if not the parent of the panel if (!drawAsWindow) { panelView.PanelExpanded = panelExpanded; panelView.ScrollingVertical = m_VerticalScrollActive; panelView.ScrollingHorizontal = m_HorizontalScrollActive; } } } m_ScrollView = scrollView.scrollPosition; } } }