Beispiel #1
0
        private void OnGUI()
        {
            Event e = Event.current;

            if (e.isMouse && e.button == 0 && e.type == EventType.MouseDown)
            {
                GUI.FocusControl("");
            }

            InitStyles();

            // Toolbar Area
            Rect rect = new Rect(0f, 0f, position.width, m_Toolbar.fixedHeight);

            GUILayout.BeginArea(new Rect(0f, 0f, position.width, m_Toolbar.fixedHeight), m_Toolbar);
            GUILayout.BeginHorizontal();
            GUILayout.Space(5f);
            TabArea();
            GUILayout.Space(5f);
            GUILayout.EndHorizontal();
            GUILayout.EndArea();

            // Left Area
            Rect leftRect = new Rect(5f, rect.height + 5f, position.width - 10f, position.height - rect.height - 10f);

            GUILayout.BeginArea(leftRect);
            SelectEditorArea(new Rect(0f, 0f, leftRect.width, leftRect.height));
            GUILayout.EndArea();

            if (OnRepaint != null)
            {
                OnRepaint.Invoke();
            }

            if (e.isMouse && e.button == 0 && e.type == EventType.MouseDown)
            {
                Repaint();
            }
        }
Beispiel #2
0
        private void End()
        {
            _allocatedMemory = true;
            var main = _blocks[0];

            main.Dispose();

            if (_currentPhase == GUIPhase.Layout)
            {
                main.ResetDimensions();
                main.Layout(_startRect);
                Height        = main.height.Value;
                _currentPhase = GUIPhase.Draw;

                if (_pendingRepaint)
                {
                    EditorHelper.RepaintAllInspectors();
                    OnRepaint.SafeInvoke();
                    _pendingRepaint = false;
                }

                #if dbg_level_1
                Debug.Log("Done layout. Deepest Block depth: {0}. Total number of blocks created: {1}. Total number of controls {2}"
                          .FormatWith(dbgMaxDepth, _blocks.Count, _controls.Count));
                #endif
            }
            else
            {
                if (_pendingReset || _nextControlIdx != _controls.Count || _nextBlockIdx != _blocks.Count)
                {
                    #if dbg_level_1
                    if (_pendingReset)
                    {
                        Debug.Log("Resetting - Theres a reset request pending");
                    }
                    else
                    {
                        Debug.Log("Resetting -  The number of controls/blocks drawn doesn't match the total number of controls/blocks");
                    }
                    #endif
                    _controls.Clear();
                    _blocks.Clear();
                    _allocatedMemory = false;
                    _pendingRepaint  = true;
                    _currentPhase    = GUIPhase.Layout;
                }
                else if (_pendingLayout)
                {
                    #if dbg_level_1
                    Debug.Log("Pending layout request. Doing layout in next phase");
                    #endif
                    _currentPhase = GUIPhase.Layout;
                    EditorHelper.RepaintAllInspectors();
                }
                else
                {
                    bool resized = _prevInspectorWidth != EditorGUIUtility.currentViewWidth;
                    if (resized)
                    {
                        #if dbg_level_1
                        Debug.Log("Resized inspector. Doing layout in next phase");
                        #endif
                        _prevInspectorWidth = EditorGUIUtility.currentViewWidth;
                        _currentPhase       = GUIPhase.Layout;
                    }
                }
            }
        }
Beispiel #3
0
 /// <summary>
 ///
 /// Invoke OnRepaint event.
 ///
 /// </summary>
 protected void InvokeRepaint()
 {
     OnRepaint?.Invoke(this);
 }
 private void HandleOnReset()
 {
     OnRepaint?.Invoke(this, EventArgs.Empty);
 }