예제 #1
0
        public static void DrawWindow(int windowId, WindowSettings window, GUI.WindowFunction func)
        {
            Rect rect = window.rect;

            if (window.isMinimized)
            {
                rect.height = 30;
            }
            GUILayout.Window(windowId, rect, func, GUIContent.none);
        }
예제 #2
0
        public static void SetSearch(WindowSettings window, string text, SearchMode searchMode, int searchIndex, bool setActive)
        {
            if (setActive)
            {
                instance.SetActive(true);
            }

            window.searchList[searchIndex].useSearch = true;
            window.searchList[searchIndex].text      = text;
            window.searchList[searchIndex].mode      = searchMode;
        }
예제 #3
0
        void Awake()
        {
#if !UNITY_EDITOR
            isDebugBuild = Debug.isDebugBuild;
#endif
            ResetStatic();
            consoleWindow = windowData.consoleWindow;

            logs      = new CullList[6];
            cullGroup = new CullGroup(logSize * logs.Length);

            for (int i = 0; i < logs.Length; i++)
            {
                logs[i] = new CullList(logSize);
            }

            SetActive(showConsoleOnStart);

            inputCommand = string.Empty;

            logs[commandLogs].cullItems.Add(new LogEntry("-------------------------------------------------------------------------------", Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry(Helper.GetApplicationInfo(), Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry("-------------------------------------------------------------------------------", Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry(string.Empty, Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry("Type '?' to list all commands", Color.white, titleFontSize, FontStyle.Bold));
            logs[commandLogs].cullItems.Add(new LogEntry(string.Empty, Color.white, titleFontSize, FontStyle.Bold));

            GUIChangeBool.ApplyUpdates();

            Register(this);

            CalcDraw(true);

#if UNITY_EDITOR
            if (testOnlyFreeConsoleCommands)
            {
                accessLevel = AccessLevel.Free;
            }
            else
            {
                accessLevel = AccessLevel.Admin;
            }
#else
            if (adminModeInBuild == AccessMode.Enabled)
            {
                accessLevel = AccessLevel.Admin;
            }
#endif
        }
예제 #4
0
        void DrawWindowTitle(GUIContent guiContent, WindowSettings window)
        {
            GUILayout.BeginHorizontal();
            DrawBox(guiContent, Color.black);
            Helper.Drag(window, inspectorWindow, hierarchyWindow, true);

            skin.button.fontStyle = FontStyle.Bold;
            if (GUILayout.Button(window.isMinimized ? "[]" : "_", GUILayout.Width(21)))
            {
                window.isMinimized = !window.isMinimized;
            }
            if (GUILayout.Button("X", GUILayout.Width(21)))
            {
                SetActive(false);
            }
            skin.button.fontStyle = FontStyle.Normal;

            GUILayout.EndHorizontal();
        }
예제 #5
0
        public Bool3 DrawElement(WindowSettings window, DrawInfo info, int childCount, string name, float width, Texture tex, string tooltip = "")
        {
            Bool3 clicked = new Bool3();

            if (childCount > 0)
            {
                GUILayout.Space(-1);
                // GUI.color = GUI.backgroundColor;
                clicked.v2 = GUILayout.Button(Helper.GetGUIContent(string.Empty, tooltip), GUILayout.Width(21), GUILayout.Height(21));
                Rect rect = GUILayoutUtility.GetLastRect();
                rect.x    += (info.foldout ? 4 : 5);
                rect.y    += (info.foldout ? 7 : 6);
                rect.width = rect.height = 8;
                GUI.DrawTexture(rect, info.foldout ? texArrowUnfolded : texArrowFolded);
                // GUI.color = GetColor(Color.white);
                GUILayout.Space(-4);
            }
            else
            {
                GUILayout.Space(5);
                DrawDot(GUI.backgroundColor, tooltip, tex);
                GUILayout.Space(5);
                // GUILayout.Toggle(true, Helper.MyGUIContent(string.Empty, tooltip), GUILayout.Width(25));
            }

            GUILayout.Space(2);

            if (width == -1)
            {
                GUILayout.Label(name);
            }
            else
            {
                GUILayout.Label(name, GUILayout.Width(width));
            }

            clicked.v3 = clicked.v1 || clicked.v2;

            return(clicked);
        }
예제 #6
0
        public static bool DoWindowsContainMousePos()
        {
            if (instance.runtimeInspector)
            {
                WindowSettings hierarchyWindow = instance.runtimeInspector.windowData.hierarchyWindow;
                WindowSettings inspectorWindow = instance.runtimeInspector.windowData.inspectorWindow;

                if (RuntimeInspector.show && (hierarchyWindow.ContainsMousePos(EventInput.mousePos) || (RuntimeInspector.ShouldInspectorWindowShow() && inspectorWindow.ContainsMousePos(EventInput.mousePos))))
                {
                    return(true);
                }
            }
            if (instance.runtimeConsole)
            {
                WindowSettings consoleWindow = instance.runtimeConsole.windowData.consoleWindow;
                if (RuntimeConsole.show && consoleWindow.ContainsMousePos(EventInput.mousePos))
                {
                    return(true);
                }
            }

            return(false);
        }
예제 #7
0
        public Bool3 DrawElement(WindowSettings window, DrawInfo info, int childCount, string text = "", Texture image = null, string tooltip = "", bool isActive = true, int prefix = 0)
        {
            Bool3 clicked = new Bool3();

            GUI.color = isActive ? Color.white : new Color(0.25f, 0.25f, 0.25f, 1);

            GUILayout.BeginHorizontal();
            if (prefix != 0)
            {
                GUILayout.Space(prefix);
            }

            if (childCount > 0 || childCount == -1)
            {
                if (windowData.showChildCount.Value && childCount > 0)
                {
                    clicked.v2 = GUILayout.Button((Helper.GetGUIContent(childCount.ToString(), info.foldout ? texArrowUnfolded : texArrowFolded)), GUILayout.Width(55), GUILayout.Height(21));
                }
                else
                {
                    clicked.v2 = GUILayout.Button(Helper.GetGUIContent(string.Empty, info.foldout ? texArrowUnfolded : texArrowFolded), GUILayout.Width(25), GUILayout.Height(21));
                }
            }
            else
            {
                GUILayout.Label(string.Empty, GUILayout.Width(windowData.showChildCount.Value ? 55 : 25), GUILayout.Height(21));
            }

            clicked.v1 = GUILayout.Button(Helper.GetGUIContent(text, image, tooltip), GUILayout.Height(21));

            GUILayout.EndHorizontal();

            GUI.color  = Color.white;
            clicked.v3 = clicked.v1 || clicked.v2;

            return(clicked);
        }
예제 #8
0
        public static bool Drag(WindowSettings window, WindowSettings inspectorWindow, WindowSettings hierarchyWindow, bool titleDrag, bool onlyRightCorner = false)
        {
            var currentEvent = Event.current;

            if (currentEvent.type == EventType.Layout)
            {
                return(false);
            }

            Rect lastRect = new Rect();

            if (titleDrag)
            {
                lastRect           = GUILayoutUtility.GetLastRect();
                lastRect.position += window.rect.position;
            }

            Vector2 mousePos = EventInput.mousePos;

            if (currentEvent.type == EventType.MouseDown && !currentEvent.shift && currentEvent.button == 0)
            {
                if (titleDrag && lastRect.Contains(mousePos))
                {
                    window.drag = 1;
                }
                else if (!titleDrag && window.rect.Contains(mousePos))
                {
                    if (onlyRightCorner)
                    {
                        if (mousePos.x > window.rect.xMax - 15 && mousePos.y > window.rect.yMax - 15)
                        {
                            window.drag |= 10;
                        }
                    }
                    else
                    {
                        if (mousePos.x > window.rect.xMax - 5)
                        {
                            window.drag |= 2;
                        }
                        else if (mousePos.x < window.rect.xMin + 7.5f && !window.isDocked.Value)
                        {
                            window.drag |= 4;
                        }
                        if (mousePos.y > window.rect.yMax - 7.5f)
                        {
                            window.drag |= 8;
                        }
                        else if (mousePos.y < window.rect.yMin + 7.5f)
                        {
                            window.drag |= 16;
                        }
                    }
                }

                lastMousePos = mousePos;
            }

            if (titleDrag)
            {
                return(false);
            }

            bool didDrag = false;

            if (window.drag != 0)
            {
                Vector2 deltaMousePos = mousePos - lastMousePos;
                lastMousePos = mousePos;

                if (window.drag == 1)
                {
                    window.position += new Vector2(deltaMousePos.x / Screen.width, deltaMousePos.y / Screen.height);
                }
                else
                {
                    if ((window.drag & 2) != 0)
                    {
                        window.rect.xMax += deltaMousePos.x * (onlyRightCorner && window.isDocked.Value ? 2 : 1);
                        if (deltaMousePos.x != 0)
                        {
                            didDrag = true;
                        }
                    }
                    if ((window.drag & 4) != 0)
                    {
                        window.rect.xMin  += deltaMousePos.x;
                        window.position.x += deltaMousePos.x / Screen.width;
                        if (deltaMousePos.x != 0)
                        {
                            didDrag = true;
                        }
                    }
                    if ((window.drag & 8) != 0)
                    {
                        if (inspectorWindow != null && inspectorWindow.isDocked.Value)
                        {
                            window = hierarchyWindow;
                        }
                        window.rect.yMax += deltaMousePos.y;
                        if (deltaMousePos.y != 0)
                        {
                            didDrag = true;
                        }
                    }
                    if ((window.drag & 16) != 0)
                    {
                        if (inspectorWindow != null && inspectorWindow.isDocked.Value)
                        {
                            window = hierarchyWindow;
                        }

                        window.rect.yMin  += deltaMousePos.y;
                        window.position.y += deltaMousePos.y / Screen.height;
                        if (deltaMousePos.y != 0)
                        {
                            didDrag = true;
                        }
                    }
                }
            }

            return(didDrag);
        }
예제 #9
0
        bool DrawSearch(WindowSettings window, bool changeText2)
        {
            List <Search> searchList = window.searchList;

            if (searchList.Count == 0)
            {
                searchList.Add(new Search());
            }

            bool hasChanged = false;

            for (int i = 0; i < searchList.Count; i++)
            {
                Search     search     = searchList[i];
                SearchMode searchMode = search.mode;

                if (!search.useSearch)
                {
                    GUI.color = Color.grey;
                }
                else if (search.hasSearch)
                {
                    GUI.backgroundColor = GetColor(Color.magenta);
                }

                GUILayout.BeginHorizontal();

                if (GUILayout.Button(Helper.GetGUIContent("Search", windowData.texSearch, "Toggle Search On/Off"), GUILayout.Width(75), GUILayout.Height(21)))
                {
                    search.useSearch = !search.useSearch;
                    hasChanged       = true;
                }
                GUI.backgroundColor = GetColor(Color.white);

                if (i == 0)
                {
                    if (GUILayout.Button(Helper.GetGUIContent("+", "Add another Search Condition"), GUILayout.Width(20)))
                    {
                        searchList.Add(new Search());
                    }
                }
                else
                {
                    if (GUILayout.Button(Helper.GetGUIContent("-", "Remove this Search Condition"), GUILayout.Width(20)))
                    {
                        if (search.useSearch && search.hasSearch)
                        {
                            hasChanged = true;
                        }
                        searchList.RemoveAt(i--);
                        continue;
                    }
                }

                if (GUILayout.Button(Helper.GetGUIContent(searchMode.ToString(), "Toggle between searching for Names/Types"), GUILayout.Width(47)))
                {
                    if (searchMode == SearchMode.Name)
                    {
                        search.mode = SearchMode.Type;
                    }
                    else
                    {
                        search.mode = SearchMode.Name;
                    }

                    if (search.useSearch && search.hasSearch)
                    {
                        hasChanged = true;
                    }
                }

                if (i == 0)
                {
                    // if (searchList.Count > 1) GUILayout.Space(24);
                    if (GUILayout.Button(Helper.GetGUIContent(window.showSearchNonFound ? windowData.texVisible : windowData.texInvisible, "Enabled: Shows all if parent object is unfolded.\n\nDisabled: Shows only found results."), GUILayout.Width(25)))
                    {
                        window.showSearchNonFound = !window.showSearchNonFound;
                    }
                }
                else
                {
                    skin.button.alignment = TextAnchor.MiddleCenter;
                    if (GUILayout.Button(Helper.GetGUIContent(search.condition == SearchCondition.Or ? "||" : "&", "|| = Or\n& = And"), GUILayout.Width(25)))
                    {
                        if (search.useSearch && search.hasSearch)
                        {
                            hasChanged = true;
                        }
                        if (search.condition == SearchCondition.Or)
                        {
                            search.condition = SearchCondition.And;
                        }
                        else
                        {
                            search.condition = SearchCondition.Or;
                        }
                    }
                    skin.button.alignment = TextAnchor.MiddleLeft;
                }

                if (GUILayout.Button(Helper.GetGUIContent("X", "Delete search text"), GUILayout.Width(22)))
                {
                    search.text      = string.Empty;
                    search.hasSearch = false;
                }

                if (search.hasSearch && search.mode == SearchMode.Type && search.types.Count == 0)
                {
                    GUI.color = Color.red;
                }
                GUI.changed = false;
                search.text = GUILayout.TextField(search.text);

                if (search.useSearch || GUI.changed)
                {
                    if (GUI.changed)
                    {
                        hasChanged = true;
                    }
                    search.hasSearch = (search.text != string.Empty);

                    if (search.mode == SearchMode.Type)
                    {
                        FastList <Type> typeList;

                        if (search.text.Contains("[]"))
                        {
                            if (typeNameLookup.TryGetValue(search.text.Replace("[]", ""), out typeList))
                            {
                                search.types.FastClear();
                                search.types.AddRange(typeList);
                                search.MakeArrayTypes();
                            }
                            // Debug.Log(search.type.FullName);
                        }
                        else if (typeNameLookup.TryGetValue(search.text, out typeList))
                        {
                            search.types.FastClear();
                            search.types.AddRange(typeList);
                        }
                        else
                        {
                            search.types.FastClear();
                        }

                        if (search.types.Count > 0 && window == hierarchyWindow && !drawAssemblies.Value && !drawMemory.Value)
                        {
                            for (int j = 0; j < search.types.Count; j++)
                            {
                                if (!search.types.items[j].IsSubclassOf(typeof(Component)))
                                {
                                    search.types.RemoveAt(j--);
                                }
                            }
                        }
                    }
                }

                GUILayout.EndHorizontal();
                GUI.color = Color.white;
            }

            return(hasChanged);
        }