Exemplo n.º 1
0
        static void EditorGlobalKeyPress()
        {
            if (Event.current.control)
            {
                //Debug.Log("ctrl true");

                ctrl = true;
            }
            else
            {
                if (ctrl)
                {
                    MinimizedWindow min = EditorWindow.focusedWindow as MinimizedWindow;

                    if (min != null)
                    {
                        min.RestoreWindow();
                    }

                    //Debug.Log("ctrl true->false");

                    ctrl = false;
                }
            }
        }
Exemplo n.º 2
0
        public static void RegisterMinimizedWindow(EditorWindow window)
        {
            if (!minimizedWindows.Contains(window))
            {
                minimizedWindows.Add(window);

                //Debug.Log(window.titleContent.text + " registered");

                needToResort = true;
            }
            else
            {
                //Debug.Log(window.titleContent.text + " already registered");
            }

            var typeName = (window as MinimizedWindow).windowTypeName;

            if (typeName != null && typeName.StartsWith("UnityEditor.InspectorWindow"))
            {
                //Debug.Log("Inspector minimized registered");

                inspectorWindowMinimized = window as MinimizedWindow;
            }
        }
Exemplo n.º 3
0
        public static void MinimizeWindowMenu()
        {
            var currentWindow = EditorWindow.focusedWindow;

            MinimizedWindow.MinimizeWindow(currentWindow);
        }
Exemplo n.º 4
0
        static void Update()
        {
            if (minimizedWindows.Count > 0)
            {
                if (handlerWindow == null)
                {
                    //Debug.Log("handlerWindow created at "+ panelPos);

                    handlerWindow = HandlerWindow.Create(panelPos, new Vector2(handleWidth, tabHeight));

                    Resort();
                }
            }
            else
            {
                if (handlerWindow != null)
                {
                    //Debug.Log("No minimizedWindows. Close handler");

                    handlerWindow.Close();
                }
            }

            if (handlerWindow != null)
            {
                if (panelPos != handlerWindow.position.position && handlerWindow.position.position != Vector2.zero)
                {
                    panelPos = handlerWindow.position.position;

                    needToResort = true;
                }
            }

            string newActiveObjectName = (Selection.activeObject != null ? Selection.activeObject.ToString() : "");

            if (Auto_inspector && activeObjectName != newActiveObjectName)
            {
                activeObjectName = newActiveObjectName;

                if (!String.IsNullOrEmpty(activeObjectName))
                {
                    //Debug.Log("activeObject: " + activeObjectName);

                    if (inspectorWindowMinimized != null)
                    {
                        inspectorWindowMinimized.RestoreWindow();

                        if (focusedWindow != null)
                        {
                            EditorWindow.FocusWindowIfItsOpen(focusedWindow.GetType());
                        }
                    }
                }
                else
                {
                    //Debug.Log("activeObject: null");
                    if (inspectorWindow != null && !CheckIsDocked(inspectorWindow))
                    {
                        bool isLocked = CheckInspectorIsLocked(inspectorWindow);

                        if (isLocked)
                        {
                            //Debug.LogWarning("locked inspector does not minimize");
                        }
                        else
                        {
                            //Debug.Log("Minimize Inspector");

                            MinimizedWindow.MinimizeWindow(inspectorWindow);
                        }
                    }
                }
            }

            if (Auto_minimize && focusedWindow != EditorWindow.focusedWindow)
            {
                if (EditorWindow.focusedWindow != null)
                {
                    if (focusedWindow != null)
                    {
                        //Debug.Log("Switch from" + focusedWindow + " to" + EditorWindow.focusedWindow);

                        if (!CheckIsDocked(focusedWindow))
                        {
                            MinimizedWindow.MinimizeWindow(focusedWindow);
                        }
                    }

                    focusedWindow = EditorWindow.focusedWindow;
                }
            }

            if (needToResort)
            {
                if (handlerWindow != null && panelPos.x + tabWidth * minimizedWindows.Count > Screen.currentResolution.width)
                {
                    handlerWindow.vertical = true;
                }

                int i = 0;

                foreach (var w in minimizedWindows)
                {
                    //Debug.Log(w.titleContent.text+" sort "+i);

                    w.minSize = new Vector2(tabWidth, tabHeight);

                    //new Rect(Screen.currentResolution.width - width, Screen.currentResolution.height - height / 2 - 100 - i * (height), width, height);
                    Rect r =
                        (handlerWindow == null || handlerWindow.vertical) ?
                        new Rect(panelPos.x + handleWidth - tabWidth, panelPos.y + tabHeight + i * tabHeight, tabWidth, tabHeight) :
                        new Rect(panelPos.x + handleWidth + tabWidth * i, panelPos.y, tabWidth, tabHeight);

                    if (w.position.position != r.position)
                    {
                        //Debug.LogWarning(w.position.position.y + " != " + r.position.y);
                        try
                        {
                            w.position = r;
                        }
                        catch (Exception e)
                        {
                            Debug.LogError(e.Message);
                        }
                    }

                    i++;
                }

                needToResort = false;
            }
        }