Пример #1
0
        public static void MinimizeWindowMenu()
        {
            var currentWindow = EditorWindow.focusedWindow;

            MinimizedWindow.MinimizeWindow(currentWindow);
        }
Пример #2
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;
            }
        }