Exemple #1
0
        private void MainWindow(int id)
        {
            GUI.DragWindow(new Rect(0, 0, MainRect.width - 90, 20));

            if (GUIHelper.Button(new Rect(MainRect.width - 90, 2, 80, 20), $"Hide ({ModConfig.Instance.Main_Menu_Toggle})"))
            {
                ExplorerCore.ShowMenu = false;
                return;
            }

            GUIHelper.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box);

            MainHeader();

            var page = Pages[m_currentPage];

            page.scroll = GUIHelper.BeginScrollView(page.scroll);

            page.DrawWindow();

            GUIHelper.EndScrollView();

            MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID);

            GUIHelper.EndArea();
        }
        private void TransformList(Rect m_rect)
        {
            GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, null);
            m_transformScroll = GUIHelper.BeginScrollView(m_transformScroll);

            GUILayout.Label("<b><size=15>Children</size></b>", new GUILayoutOption[0]);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            ChildPages.DrawLimitInputArea();

            if (ChildPages.ItemCount > ChildPages.ItemsPerPage)
            {
                ChildPages.CurrentPageLabel();

                GUILayout.EndHorizontal();
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) }))
                {
                    ChildPages.TurnPage(Turn.Left, ref this.m_transformScroll);
                }
                if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) }))
                {
                    ChildPages.TurnPage(Turn.Right, ref this.m_transformScroll);
                }
            }
            GUILayout.EndHorizontal();

            if (m_children != null && m_children.Length > 0)
            {
                int start = ChildPages.CalculateOffsetIndex();

                for (int j = start; (j < start + ChildPages.ItemsPerPage && j < ChildPages.ItemCount); j++)
                {
                    var obj = m_children[j];

                    if (!obj)
                    {
                        GUILayout.Label("null", new GUILayoutOption[0]);
                        continue;
                    }

                    Buttons.GameObjectButton(obj.gameObject, InspectGameObject, false, m_rect.width / 2 - 80);
                }
            }
            else
            {
                GUILayout.Label("<i>None</i>", new GUILayoutOption[0]);
            }

            GUIHelper.EndScrollView();
            GUILayout.EndVertical();
        }
Exemple #3
0
        // =========== GUI DRAW ============= //

        public override void DrawWindow()
        {
            try
            {
                // helpers
                GUIHelper.BeginHorizontal(GUIContent.none, GUI.skin.box, null);
                GUILayout.Label("<b><color=orange>Helpers</color></b>", new GUILayoutOption[] { GUILayout.Width(70) });
                if (GUILayout.Button("Find Static Instances", new GUILayoutOption[] { GUILayout.Width(180) }))
                {
                    CacheResults(GetStaticInstances());
                }
                if (GUILayout.Button("Find Static Classes", new GUILayoutOption[] { GUILayout.Width(180) }))
                {
                    CacheResults(GetStaticClasses(), true);
                }
                GUILayout.EndHorizontal();

                // search box
                SearchBox();

                // results
                GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, null);

                GUI.skin.label.alignment = TextAnchor.MiddleCenter;
                GUILayout.Label("<b><color=orange>Results </color></b>" + " (" + m_searchResults.Count + ")", new GUILayoutOption[0]);
                GUI.skin.label.alignment = TextAnchor.UpperLeft;

                int count = m_searchResults.Count;

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                Pages.DrawLimitInputArea();

                if (count > Pages.ItemsPerPage)
                {
                    // prev/next page buttons

                    if (Pages.ItemCount > Pages.ItemsPerPage)
                    {
                        if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) }))
                        {
                            Pages.TurnPage(Turn.Left, ref this.resultsScroll);
                        }

                        Pages.CurrentPageLabel();

                        if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) }))
                        {
                            Pages.TurnPage(Turn.Right, ref this.resultsScroll);
                        }
                    }
                }

                GUILayout.EndHorizontal();

                resultsScroll = GUIHelper.BeginScrollView(resultsScroll);

                var _temprect = new Rect(MainMenu.MainRect.x, MainMenu.MainRect.y, MainMenu.MainRect.width + 160, MainMenu.MainRect.height);

                if (m_searchResults.Count > 0)
                {
                    int offset = Pages.CalculateOffsetIndex();

                    for (int i = offset; i < offset + Pages.ItemsPerPage && i < count; i++)
                    {
                        if (i >= m_searchResults.Count)
                        {
                            break;
                        }

                        m_searchResults[i].Draw(MainMenu.MainRect, 0f);
                    }
                }
                else
                {
                    GUILayout.Label("<color=red><i>No results found!</i></color>", new GUILayoutOption[0]);
                }

                GUIHelper.EndScrollView();
                GUILayout.EndVertical();
            }
            catch (Exception e)
            {
                if (!e.Message.Contains("in a group with only"))
                {
                    ExplorerCore.Log("Exception drawing search results!");
                    while (e != null)
                    {
                        ExplorerCore.Log(e);
                        e = e.InnerException;
                    }
                    m_searchResults.Clear();
                }
            }
        }
Exemple #4
0
        public override void DrawWindow()
        {
            GUILayout.Label("<b><size=15><color=cyan>C# Console</color></size></b>", new GUILayoutOption[0]);

            GUI.skin.label.alignment = TextAnchor.UpperLeft;

            // SCRIPT INPUT

            GUILayout.Label("Enter code here as though it is a method body:", new GUILayoutOption[0]);

            inputAreaScroll = GUIHelper.BeginScrollView(
                inputAreaScroll,
                new GUILayoutOption[] { GUILayout.Height(250), GUIHelper.ExpandHeight(true) }
                );

            GUI.SetNextControlName(INPUT_CONTROL_NAME);
            m_input = GUIHelper.TextArea(m_input, new GUILayoutOption[] { GUIHelper.ExpandHeight(true) });

            GUIHelper.EndScrollView();

            // EXECUTE BUTTON

            if (GUILayout.Button("<color=cyan><b>Execute</b></color>", new GUILayoutOption[0]))
            {
                try
                {
                    m_input = m_input.Trim();

                    if (!string.IsNullOrEmpty(m_input))
                    {
                        Evaluate(m_input);

                        //var result = Evaluate(m_input);

                        //if (result != null && !Equals(result, VoidType.Value))
                        //{
                        //    ExplorerCore.Log("[Console Output]\r\n" + result.ToString());
                        //}
                    }
                }
                catch (Exception e)
                {
                    ExplorerCore.LogError("Exception compiling!\r\nMessage: " + e.Message + "\r\nStack: " + e.StackTrace);
                }
            }

            // SUGGESTIONS
            if (AutoCompletes.Count > 0)
            {
                autocompleteScroll = GUIHelper.BeginScrollView(autocompleteScroll, new GUILayoutOption[] { GUILayout.Height(150) });

                var origSkin = GUI.skin.button;
                GUI.skin.button = AutocompleteStyle;

                foreach (var autocomplete in AutoCompletes)
                {
                    AutocompleteStyle.normal.textColor = autocomplete.TextColor;
                    if (GUILayout.Button(autocomplete.Full, new GUILayoutOption[] { GUILayout.Width(MainMenu.MainRect.width - 50) }))
                    {
                        UseAutocomplete(autocomplete.Addition);
                        break;
                    }
                }

                GUI.skin.button = origSkin;

                GUIHelper.EndScrollView();
            }

            if (shouldRefocus)
            {
                GUI.FocusControl(INPUT_CONTROL_NAME);
                shouldRefocus = false;
            }

            // USING DIRECTIVES

            GUILayout.Label("<b>Using directives:</b>", new GUILayoutOption[0]);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(105) });
            m_usingInput = GUIHelper.TextField(m_usingInput, new GUILayoutOption[] { GUILayout.Width(150) });
            if (GUILayout.Button("<b><color=lime>Add</color></b>", new GUILayoutOption[] { GUILayout.Width(120) }))
            {
                AddUsing(m_usingInput);
            }
            if (GUILayout.Button("<b><color=red>Clear All</color></b>", new GUILayoutOption[] { GUILayout.Width(120) }))
            {
                ResetConsole();
            }
            GUILayout.EndHorizontal();

            foreach (var asm in UsingDirectives)
            {
                GUILayout.Label(AsmToUsing(asm, true), new GUILayoutOption[0]);
            }

            CheckAutocomplete();
        }
        private void ComponentList(Rect m_rect)
        {
            GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, null);
            m_compScroll = GUIHelper.BeginScrollView(m_compScroll);
            GUILayout.Label("<b><size=15>Components</size></b>", new GUILayoutOption[0]);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            CompPages.DrawLimitInputArea();

            if (CompPages.ItemCount > CompPages.ItemsPerPage)
            {
                CompPages.CurrentPageLabel();

                GUILayout.EndHorizontal();
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                if (GUILayout.Button("< Prev", new GUILayoutOption[] { GUILayout.Width(80) }))
                {
                    CompPages.TurnPage(Turn.Left, ref this.m_compScroll);
                }
                if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) }))
                {
                    CompPages.TurnPage(Turn.Right, ref this.m_compScroll);
                }
            }
            GUILayout.EndHorizontal();

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            var width = m_rect.width / 2 - 135f;

            m_addComponentInput = GUIHelper.TextField(m_addComponentInput, new GUILayoutOption[] { GUILayout.Width(width) });
            if (GUILayout.Button("Add Comp", new GUILayoutOption[0]))
            {
                if (ReflectionHelpers.GetTypeByName(m_addComponentInput) is Type compType)
                {
                    if (typeof(Component).IsAssignableFrom(compType))
                    {
#if CPP
                        TargetGO.AddComponent(Il2CppType.From(compType));
#else
                        TargetGO.AddComponent(compType);
#endif
                    }
                    else
                    {
                        ExplorerCore.LogWarning($"Type '{compType.Name}' is not assignable from Component!");
                    }
                }
                else
                {
                    ExplorerCore.LogWarning($"Could not find a type by the name of '{m_addComponentInput}'!");
                }
            }
            GUILayout.EndHorizontal();

            GUI.skin.button.alignment = TextAnchor.MiddleLeft;
            if (m_cachedDestroyList.Count > 0)
            {
                m_cachedDestroyList.Clear();
            }

            if (m_components != null)
            {
                int start = CompPages.CalculateOffsetIndex();

                for (int j = start; (j < start + CompPages.ItemsPerPage && j < CompPages.ItemCount); j++)
                {
                    var component = m_components[j];

                    if (!component)
                    {
                        continue;
                    }

                    var type =
#if CPP
                        component.GetIl2CppType();
#else
                        component.GetType();
#endif
                    GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                    if (ReflectionHelpers.BehaviourType.IsAssignableFrom(type))
                    {
#if CPP
                        BehaviourEnabledBtn(component.TryCast <Behaviour>());
#else
                        BehaviourEnabledBtn(component as Behaviour);
#endif
                    }
                    else
                    {
                        GUIHelper.Space(26);
                    }
                    if (GUILayout.Button("<color=cyan>" + type.Name + "</color>", new GUILayoutOption[] { GUILayout.Width(m_rect.width / 2 - 100) }))
                    {
                        ReflectObject(component);
                    }
                    if (GUILayout.Button("<color=red>-</color>", new GUILayoutOption[] { GUILayout.Width(20) }))
                    {
                        m_cachedDestroyList.Add(component);
                    }
                    GUILayout.EndHorizontal();
                }
            }

            GUI.skin.button.alignment = TextAnchor.MiddleCenter;
            if (m_cachedDestroyList.Count > 0)
            {
                for (int i = m_cachedDestroyList.Count - 1; i >= 0; i--)
                {
                    var comp = m_cachedDestroyList[i];
                    GameObject.Destroy(comp);
                }
            }

            GUIHelper.EndScrollView();

            GUILayout.EndVertical();
        }
        public override void WindowFunction(int windowID)
        {
            if (pendingDestroy)
            {
                return;
            }

            try
            {
                var rect = WindowManager.TabView ? TabViewWindow.Instance.m_rect : this.m_rect;

                if (!WindowManager.TabView)
                {
                    Header();
                    GUIHelper.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box);
                }

                scroll = GUIHelper.BeginScrollView(scroll);

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label("Scene: <color=cyan>" + (m_scene == "" ? "n/a" : m_scene) + "</color>", new GUILayoutOption[0]);
                if (m_scene == UnityHelpers.ActiveSceneName)
                {
                    if (GUILayout.Button("<color=#00FF00>Send to Scene View</color>", new GUILayoutOption[] { GUILayout.Width(150) }))
                    {
                        ScenePage.Instance.SetTransformTarget(TargetGO.transform);
                        MainMenu.SetCurrentPage(0);
                    }
                }
                if (GUILayout.Button("Reflection Inspect", new GUILayoutOption[] { GUILayout.Width(150) }))
                {
                    WindowManager.InspectObject(Target, out _, true);
                }
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label("Path:", new GUILayoutOption[] { GUILayout.Width(50) });
                string pathlabel = TargetGO.transform.GetGameObjectPath();
                if (TargetGO.transform.parent != null)
                {
                    if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) }))
                    {
                        InspectGameObject(TargetGO.transform.parent);
                    }
                }
                GUIHelper.TextArea(pathlabel, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label("Name:", new GUILayoutOption[] { GUILayout.Width(50) });
                GUIHelper.TextArea(m_name, new GUILayoutOption[0]);
                GUILayout.EndHorizontal();

                LayerControls();

                // --- Horizontal Columns section ---
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                GUIHelper.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) });
                TransformList(rect);
                GUILayout.EndVertical();

                GUIHelper.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) });
                ComponentList(rect);
                GUILayout.EndVertical();

                GUILayout.EndHorizontal(); // end horiz columns

                GameObjectControls();

                GUIHelper.EndScrollView();

                if (!WindowManager.TabView)
                {
                    m_rect = ResizeDrag.ResizeWindow(rect, windowID);

                    GUIHelper.EndArea();
                }
            }
            catch (Exception e)
            {
                DestroyOnException(e);
            }
        }