Exemple #1
0
        private void DrawPageButtons()
        {
            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

            Pages.DrawLimitInputArea();

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

                    Update_Impl();
                }

                Pages.CurrentPageLabel();

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

                    Update_Impl();
                }
            }

            GUILayout.EndHorizontal();
            GUI.skin.label.alignment = TextAnchor.UpperLeft;
        }
Exemple #2
0
        public void DrawInstanceControls(Rect rect)
        {
            //if (m_uObj)
            //{
            //    GUILayout.Label("Name: " + m_uObj.name, new GUILayoutOption[0]);
            //}
            //GUILayout.EndHorizontal();

            if (m_uObj)
            {
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label("<b>Tools:</b>", new GUILayoutOption[] { GUILayout.Width(80) });
                Buttons.InstantiateButton(m_uObj);
                if (m_component && m_component.gameObject is GameObject obj)
                {
                    GUI.skin.label.alignment = TextAnchor.MiddleRight;
                    GUILayout.Label("GameObject:", new GUILayoutOption[] { GUILayout.Width(135) });
                    var charWidth = obj.name.Length * 15;
                    var maxWidth  = rect.width - 350;
                    var btnWidth  = charWidth < maxWidth ? charWidth : maxWidth;
                    if (GUILayout.Button("<color=#00FF00>" + obj.name + "</color>", new GUILayoutOption[] { GUILayout.Width(btnWidth) }))
                    {
                        WindowManager.InspectObject(obj, out bool _);
                    }
                    GUI.skin.label.alignment = TextAnchor.UpperLeft;
                }
                else
                {
                    GUILayout.Label("Name: " + m_uObj.name, new GUILayoutOption[0]);
                }
                GUILayout.EndHorizontal();
            }
        }
Exemple #3
0
        private void DrawTextureControls()
        {
            GUIHelper.BeginHorizontal();

            GUILayout.Label("Save folder:", new GUILayoutOption[] { GUILayout.Width(80f) });
            saveFolder = GUIHelper.TextField(saveFolder, new GUILayoutOption[0]);
            GUIHelper.Space(10f);

            GUILayout.EndHorizontal();

            if (GUILayout.Button("Save to PNG", new GUILayoutOption[] { GUILayout.Width(100f) }))
            {
                var name = RemoveInvalidFilenameChars(currentTex.name ?? "");
                if (string.IsNullOrEmpty(name))
                {
                    if (OwnerCacheObject is CacheMember cacheMember)
                    {
                        name = cacheMember.MemInfo.Name;
                    }
                    else
                    {
                        name = "UNTITLED";
                    }
                }

                Texture2DHelpers.SaveTextureAsPNG(currentTex, saveFolder, name, false);

                ExplorerCore.Log($@"Saved to {saveFolder}\{name}.png!");
            }
        }
Exemple #4
0
        public override void DrawValue(Rect window, float width)
        {
            GUIHelper.BeginVertical();

            GUIHelper.BeginHorizontal();

            if (currentTex && !IsExpanded)
            {
                if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    IsExpanded = true;
                    GetGUIContent();
                }
            }
            else if (currentTex)
            {
                if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    IsExpanded = false;
                }
            }

            base.DrawValue(window, width);

            GUILayout.EndHorizontal();

            if (currentTex && IsExpanded)
            {
                DrawTextureControls();
                DrawTexture();
            }

            GUILayout.EndVertical();
        }
Exemple #5
0
        public void DrawArgsInput()
        {
            GUILayout.Label($"<b><color=orange>Arguments:</color></b>", new GUILayoutOption[0]);
            for (int i = 0; i < this.m_arguments.Length; i++)
            {
                var name  = this.m_arguments[i].Name;
                var input = this.m_argumentInput[i];
                var type  = this.m_arguments[i].ParameterType.Name;

                var label = $"<color={Syntax.Class_Instance}>{type}</color> ";
                label += $"<color={Syntax.Local}>{name}</color>";
                if (HasDefaultValue(this.m_arguments[i]))
                {
                    label = $"<i>[{label} = {this.m_arguments[i].DefaultValue ?? "null"}]</i>";
                }

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

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

                GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) });
                GUILayout.Label(label, new GUILayoutOption[] { GUIHelper.ExpandWidth(false) });
                this.m_argumentInput[i] = GUIHelper.TextField(input, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });

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

                GUILayout.EndHorizontal();
            }
        }
Exemple #6
0
        private void DrawHeaderArea()
        {
            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

            // Current Scene label
            GUILayout.Label("Current Scene:", new GUILayoutOption[] { GUILayout.Width(120) });
            SceneChangeButtons();
            GUILayout.Label("<color=cyan>" + m_currentScene + "</color>", new GUILayoutOption[0]);

            GUILayout.EndHorizontal();

            // ----- GameObject Search -----
            GUIHelper.BeginHorizontal(GUIContent.none, GUI.skin.box, null);
            GUILayout.Label("<b>Search Scene:</b>", new GUILayoutOption[] { GUILayout.Width(100) });

            m_searchInput = GUIHelper.TextField(m_searchInput, new GUILayoutOption[0]);

            if (GUILayout.Button("Search", new GUILayoutOption[] { GUILayout.Width(80) }))
            {
                Search();
            }
            GUILayout.EndHorizontal();

            GUIHelper.Space(5);
        }
Exemple #7
0
        private void DrawGameObjectList()
        {
            if (m_currentTransform != null)
            {
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                if (GUILayout.Button("<-", new GUILayoutOption[] { GUILayout.Width(35) }))
                {
                    TraverseUp();
                }
                else
                {
                    GUILayout.Label("<color=cyan>" + m_currentTransform.GetGameObjectPath() + "</color>",
                                    new GUILayoutOption[] { GUILayout.Width(MainMenu.MainRect.width - 187f) });
                }

                Buttons.InspectButton(m_currentTransform);

                GUILayout.EndHorizontal();
            }
            else
            {
                GUILayout.Label("Scene Root GameObjects:", new GUILayoutOption[0]);
            }

            if (m_objectList.Count > 0)
            {
                for (int i = 0; i < m_objectList.Count; i++)
                {
                    var obj = m_objectList[i];

                    if (obj == null)
                    {
                        continue;
                    }

                    try
                    {
                        var go = obj.IValue.Value as GameObject ?? (obj.IValue.Value as Transform)?.gameObject;

                        if (!go)
                        {
                            string label = "<color=red><i>null";

                            if (go != null)
                            {
                                label += " (Destroyed)";
                            }

                            label += "</i></color>";
                            GUILayout.Label(label, new GUILayoutOption[0]);
                        }
                        else
                        {
                            Buttons.GameObjectButton(go, SetTransformTarget, true, MainMenu.MainRect.width - 170f);
                        }
                    }
                    catch { }
                }
            }
        }
        private void LayerControls()
        {
            GUIHelper.BeginHorizontal();
            GUILayout.Label("Layer:", new GUILayoutOption[] { GUILayout.Width(50) });

            if (GUILayout.Button("<", new GUILayoutOption[] { GUILayout.Width(30) }))
            {
                if (m_layer > 0)
                {
                    m_layer--;
                    if (TargetGO)
                    {
                        TargetGO.layer = m_layer;
                    }
                }
            }
            if (GUILayout.Button(">", new GUILayoutOption[] { GUILayout.Width(30) }))
            {
                if (m_layer < 32)
                {
                    m_layer++;
                    if (TargetGO)
                    {
                        TargetGO.layer = m_layer;
                    }
                }
            }

            GUILayout.Label($"{m_layer} (<color=cyan>{LayerMaskUnstrip.LayerToName(m_layer)}</color>)",
                            new GUILayoutOption[] { GUILayout.Width(200) });

            GUILayout.EndHorizontal();
        }
        public override void DrawValue(Rect window, float width)
        {
            if (OwnerCacheObject.CanWrite)
            {
                if (!IsExpanded)
                {
                    if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = true;
                    }
                }
                else
                {
                    if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = false;
                    }
                }
            }

            GUILayout.Label($"<color=#2df7b2>Quaternion</color>: {((Quaternion)Value).eulerAngles.ToString()}", new GUILayoutOption[0]);

            if (OwnerCacheObject.CanWrite && IsExpanded)
            {
                GUILayout.EndHorizontal();

                var whitespace = CalcWhitespace(window);

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
                x = GUIHelper.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
                y = GUIHelper.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
                z = GUIHelper.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                // draw set value button
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
                {
                    SetValueFromInput();
                }
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            }
        }
Exemple #10
0
        private Vector3 TranslateControl(TranslateType mode, ref float amount, bool multByTime)
        {
            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"<color=cyan><b>{(m_localContext ? "Local " : "")}{mode}</b></color>:",
                            new GUILayoutOption[] { GUILayout.Width(m_localContext ? 110 : 65) });

            var transform = TargetGO.transform;

            switch (mode)
            {
            case TranslateType.Position:
                var pos = m_localContext ? transform.localPosition : transform.position;
                GUILayout.Label(pos.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
                break;

            case TranslateType.Rotation:
                var rot = m_localContext ? transform.localEulerAngles : transform.eulerAngles;
                GUILayout.Label(rot.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
                break;

            case TranslateType.Scale:
                GUILayout.Label(transform.localScale.ToString(), new GUILayoutOption[] { GUILayout.Width(250) });
                break;
            }
            GUILayout.EndHorizontal();

            Vector3 input = m_cachedInput[(int)mode];

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUI.skin.label.alignment = TextAnchor.MiddleRight;

            GUILayout.Label("<color=cyan>X:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
            PlusMinusFloat(ref input.x, amount, multByTime);

            GUILayout.Label("<color=cyan>Y:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
            PlusMinusFloat(ref input.y, amount, multByTime);

            GUILayout.Label("<color=cyan>Z:</color>", new GUILayoutOption[] { GUILayout.Width(20) });
            PlusMinusFloat(ref input.z, amount, multByTime);

            GUILayout.Label("+/-:", new GUILayoutOption[] { GUILayout.Width(30) });
            var amountInput = amount.ToString("F3");

            amountInput = GUIHelper.TextField(amountInput, new GUILayoutOption[] { GUILayout.Width(60) });
            if (float.TryParse(amountInput, out float f))
            {
                amount = f;
            }

            GUI.skin.label.alignment = TextAnchor.UpperLeft;
            GUILayout.EndHorizontal();

            return(input);
        }
Exemple #11
0
        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 #12
0
        public override void DrawValue(Rect window, float width)
        {
            if (m_isBool)
            {
                var b     = (bool)Value;
                var label = $"<color={(b ? "lime" : "red")}>{b}</color>";

                if (OwnerCacheObject.CanWrite)
                {
                    Value = GUILayout.Toggle(b, label, new GUILayoutOption[] { GUILayout.Width(60) });
                    DrawApplyButton();
                    //if (b != (bool)Value)
                    //{
                    //    Value = b;
                    //    OwnerCacheObject.SetValue();
                    //}
                }
                else
                {
                    GUILayout.Label(label, new GUILayoutOption[0]);
                }

                return;
            }

            // all other non-bool values use TextField

            GUIHelper.BeginVertical(new GUILayoutOption[0]);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

            GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) });

            m_valueToString = GUIHelper.TextArea(m_valueToString, new GUILayoutOption[] { GUIHelper.ExpandWidth(true) });

            DrawApplyButton();

            if (ModConfig.Instance.Bitwise_Support && m_canBitwiseOperate)
            {
                m_inBitwiseMode = GUILayout.Toggle(m_inBitwiseMode, "Bitwise?", new GUILayoutOption[0]);
            }

            GUIHelper.Space(10);

            GUILayout.EndHorizontal();

            if (ModConfig.Instance.Bitwise_Support && m_inBitwiseMode)
            {
                DrawBitwise();
            }

            GUILayout.EndVertical();
        }
Exemple #13
0
        public void DrawGenericArgsInput()
        {
            GUILayout.Label($"<b><color=orange>Generic Arguments:</color></b>", new GUILayoutOption[0]);

            for (int i = 0; i < this.GenericArgs.Length; i++)
            {
                string types = "";
                if (this.GenericConstraints[i].Length > 0)
                {
                    foreach (var constraint in this.GenericConstraints[i])
                    {
                        if (types != "")
                        {
                            types += ", ";
                        }

                        string type;

                        if (constraint == null)
                        {
                            type = "Any";
                        }
                        else
                        {
                            type = constraint.ToString();
                        }

                        types += $"<color={Syntax.Class_Instance}>{type}</color>";
                    }
                }
                else
                {
                    types = $"<color={Syntax.Class_Instance}>Any</color>";
                }
                var input = this.GenericArgInput[i];

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                GUI.skin.label.alignment = TextAnchor.MiddleCenter;
                GUILayout.Label(
                    $"<color={Syntax.StructGreen}>{this.GenericArgs[i].Name}</color>",
                    new GUILayoutOption[] { GUILayout.Width(15) }
                    );
                this.GenericArgInput[i]  = GUIHelper.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) });
                GUI.skin.label.alignment = TextAnchor.MiddleLeft;
                GUILayout.Label(types, new GUILayoutOption[0]);

                GUILayout.EndHorizontal();
            }
        }
Exemple #14
0
        public override void DrawValue(Rect window, float width)
        {
            if (OwnerCacheObject.CanWrite)
            {
                if (!IsExpanded)
                {
                    if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = true;
                    }
                }
                else
                {
                    if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = false;
                    }
                }
            }

            GUILayout.Label(Value.ToString() + "<color=#2df7b2><i> (" + ValueType + ")</i></color>", new GUILayoutOption[0]);

            if (IsExpanded)
            {
                GUILayout.EndHorizontal();

                var whitespace = CalcWhitespace(window);

                for (int i = 0; i < EnumNames.Length; i++)
                {
                    GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                    GUIHelper.Space(whitespace);

                    m_enabledFlags[i] = GUILayout.Toggle(m_enabledFlags[i], EnumNames[i], new GUILayoutOption[0]);

                    GUILayout.EndHorizontal();
                }

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
                {
                    SetFlagsFromInput();
                }
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            }
        }
Exemple #15
0
        private void MainHeader()
        {
            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            for (int i = 0; i < Pages.Count; i++)
            {
                if (m_currentPage == i)
                {
                    GUI.color = Color.green;
                }
                else
                {
                    GUI.color = Color.white;
                }

                if (GUILayout.Button(Pages[i].Name, new GUILayoutOption[0]))
                {
                    m_currentPage = i;
                }
            }
            GUILayout.EndHorizontal();

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUI.color = Color.white;
            InspectUnderMouse.EnableInspect = GUILayout.Toggle(InspectUnderMouse.EnableInspect, "Inspect Under Mouse (Shift + RMB)", new GUILayoutOption[0]);

            bool mouseState = ForceUnlockCursor.Unlock;
            bool setMouse   = GUILayout.Toggle(mouseState, "Force Unlock Mouse (Left Alt)", new GUILayoutOption[0]);

            if (setMouse != mouseState)
            {
                ForceUnlockCursor.Unlock = setMouse;
            }

            //WindowManager.TabView = GUILayout.Toggle(WindowManager.TabView, "Tab View", new GUILayoutOption[0]);
            GUILayout.EndHorizontal();

            //GUIUnstrip.Space(10);
            GUIHelper.Space(10);

            GUI.color = Color.white;
        }
Exemple #16
0
        public static Rect ResizeWindow(Rect _rect, int ID)
        {
            if (!RESIZE_FAILED)
            {
                var origRect = _rect;

                try
                {
                    GUIHelper.BeginHorizontal(GUIContent.none, GUI.skin.box, null);

                    GUI.skin.label.alignment = TextAnchor.MiddleCenter;
#if BIE
#if CPP             // Temporary for BepInEx IL2CPP
                    GUILayout.Button("<-- Drag to resize -->", new GUILayoutOption[] { GUILayout.Height(15) });
#else
                    GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) });
#endif
#else
                    GUILayout.Button(gcDrag, GUI.skin.label, new GUILayoutOption[] { GUILayout.Height(15) });
#endif

                    var resizeDragArea = GUIHelper.GetLastRect();
                    var mousePos       = InputManager.MousePosition;

                    try
                    {
                        var mouse = GUIHelper.ScreenToGUIPoint(new Vector2(mousePos.x, Screen.height - mousePos.y));
                        if (resizeDragArea.Contains(mouse))
                        {
                            IsMouseInResizeArea = true;

                            if (InputManager.GetMouseButtonDown(0))
                            {
                                IsResizing      = true;
                                m_currentWindow = ID;
                                m_currentResize = new Rect(mouse.x, mouse.y, _rect.width, _rect.height);
                            }
                        }
                        else if (!InputManager.GetMouseButton(0))
                        {
                            IsMouseInResizeArea = false;
                            IsResizing          = false;
                        }

                        if (IsResizing && ID == m_currentWindow)
                        {
                            _rect.width  = Mathf.Max(100, m_currentResize.width + (mouse.x - m_currentResize.x));
                            _rect.height = Mathf.Max(100, m_currentResize.height + (mouse.y - m_currentResize.y));
                            _rect.xMax   = Mathf.Min(Screen.width, _rect.xMax);  // modifying xMax affects width, not x
                            _rect.yMax   = Mathf.Min(Screen.height, _rect.yMax); // modifying yMax affects height, not y
                        }
                    }
                    catch
                    {
                        // throw safe Managed exception
                        throw new Exception("");
                    }

                    GUILayout.EndHorizontal();
                }
                catch (Exception e) when(e.Message.StartsWith("System.ArgumentException"))
                {
                    // suppress
                    return(origRect);
                }
                catch (Exception e)
                {
                    RESIZE_FAILED = true;
                    ExplorerCore.Log("Exception on GuiResize: " + e.GetType() + ", " + e.Message);
                    //ExplorerCore.Log(e.StackTrace);
                    return(origRect);
                }
            }
            else
            {
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                GUILayout.Label("Resize window:", new GUILayoutOption[] { GUILayout.Width(100) });

                GUI.skin.label.alignment = TextAnchor.MiddleRight;
                GUILayout.Label("<color=cyan>Width:</color>", new GUILayoutOption[] { GUILayout.Width(60) });
                if (GUIHelper.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) }))
                {
                    _rect.width -= 5f;
                }
                if (GUIHelper.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) }))
                {
                    _rect.width += 5f;
                }
                GUILayout.Label("<color=cyan>Height:</color>", new GUILayoutOption[] { GUILayout.Width(60) });
                if (GUIHelper.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) }))
                {
                    _rect.height -= 5f;
                }
                if (GUIHelper.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) }))
                {
                    _rect.height += 5f;
                }

                GUILayout.EndHorizontal();
            }

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

            return(_rect);
        }
Exemple #17
0
        private void GameObjectControls()
        {
            if (m_hideControls)
            {
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Label("<b><size=15>GameObject Controls</size></b>", new GUILayoutOption[] { GUILayout.Width(200) });
                if (GUILayout.Button("^ Show ^", new GUILayoutOption[] { GUILayout.Width(75) }))
                {
                    m_hideControls = false;
                }
                GUILayout.EndHorizontal();

                return;
            }

            GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) });

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("<b><size=15>GameObject Controls</size></b>", new GUILayoutOption[] { GUILayout.Width(200) });
            if (GUILayout.Button("v Hide v", new GUILayoutOption[] { GUILayout.Width(75) }))
            {
                m_hideControls = true;
            }
            GUILayout.EndHorizontal();

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            bool m_active = TargetGO.activeSelf;

            m_active = GUILayout.Toggle(m_active, (m_active ? "<color=lime>Enabled " : "<color=red>Disabled") + "</color>",
                                        new GUILayoutOption[] { GUILayout.Width(80) });
            if (TargetGO.activeSelf != m_active)
            {
                TargetGO.SetActive(m_active);
            }

            Buttons.InstantiateButton(TargetGO, 100);

            if (GUILayout.Button("Set DontDestroyOnLoad", new GUILayoutOption[] { GUILayout.Width(170) }))
            {
                GameObject.DontDestroyOnLoad(TargetGO);
                TargetGO.hideFlags |= HideFlags.DontUnloadUnusedAsset;
            }

            var lbl = m_freeze ? "<color=lime>Unfreeze</color>" : "<color=orange>Freeze Pos/Rot</color>";

            if (GUILayout.Button(lbl, new GUILayoutOption[] { GUILayout.Width(110) }))
            {
                m_freeze = !m_freeze;
                if (m_freeze)
                {
                    UpdateFreeze();
                }
            }

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

            m_setParentInput = GUIHelper.TextField(m_setParentInput, new GUILayoutOption[0]);
            if (GUILayout.Button("Set Parent", new GUILayoutOption[] { GUILayout.Width(80) }))
            {
                if (GameObject.Find(m_setParentInput) is GameObject newparent)
                {
                    TargetGO.transform.parent = newparent.transform;
                }
                else
                {
                    ExplorerCore.LogWarning($"Could not find gameobject '{m_setParentInput}'");
                }
            }

            if (GUILayout.Button("Detach from parent", new GUILayoutOption[] { GUILayout.Width(160) }))
            {
                TargetGO.transform.parent = null;
            }
            GUILayout.EndHorizontal();

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

            m_cachedInput[0] = TranslateControl(TranslateType.Position, ref m_translateAmount, false);
            m_cachedInput[1] = TranslateControl(TranslateType.Rotation, ref m_rotateAmount, true);
            m_cachedInput[2] = TranslateControl(TranslateType.Scale, ref m_scaleAmount, false);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            if (GUILayout.Button("<color=lime>Apply to Transform</color>", new GUILayoutOption[0]) || m_autoApplyTransform)
            {
                if (m_localContext)
                {
                    TargetGO.transform.localPosition    = m_cachedInput[0];
                    TargetGO.transform.localEulerAngles = m_cachedInput[1];
                }
                else
                {
                    TargetGO.transform.position    = m_cachedInput[0];
                    TargetGO.transform.eulerAngles = m_cachedInput[1];
                }
                TargetGO.transform.localScale = m_cachedInput[2];

                if (m_freeze)
                {
                    UpdateFreeze();
                }
            }
            if (GUILayout.Button("<color=lime>Update from Transform</color>", new GUILayoutOption[0]) || m_autoUpdateTransform)
            {
                CacheTransformValues();
            }
            GUILayout.EndHorizontal();

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            BoolToggle(ref m_autoApplyTransform, "Auto-apply to Transform?");
            BoolToggle(ref m_autoUpdateTransform, "Auto-update from transform?");
            GUILayout.EndHorizontal();

            bool b = m_localContext;

            b = GUILayout.Toggle(b, "<color=" + (b ? "lime" : "orange") + ">Use local transform values?</color>", new GUILayoutOption[0]);
            if (b != m_localContext)
            {
                m_localContext = b;
                CacheTransformValues();
                if (m_freeze)
                {
                    UpdateFreeze();
                }
            }

            GUILayout.EndVertical();

            if (GUILayout.Button("<color=red><b>Destroy</b></color>", new GUILayoutOption[] { GUILayout.Width(120) }))
            {
                GameObject.Destroy(TargetGO);
                DestroyWindow();
                return;
            }

            GUILayout.EndVertical();
        }
Exemple #18
0
        public override void WindowFunction(int windowID)
        {
            try
            {
                GUI.DragWindow(new Rect(0, 0, m_rect.width - 90, 20));
                if (GUIHelper.Button(new Rect(m_rect.width - 90, 2, 80, 20), "<color=red>Close All</color>"))
                {
                    foreach (var window in WindowManager.Windows)
                    {
                        window.DestroyWindow();
                    }
                    return;
                }

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

                GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, null);
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUI.skin.button.alignment = TextAnchor.MiddleLeft;
                int tabPerRow = (int)Math.Floor(m_rect.width / 238);
                int rowCount  = 0;
                for (int i = 0; i < WindowManager.Windows.Count; i++)
                {
                    var window = WindowManager.Windows[i];

                    // Prevent trying to draw destroyed UnityEngine.Objects
                    // before the WindowManager removes them.
                    if (window.Target is UnityEngine.Object uObj && !uObj)
                    {
                        continue;
                    }

                    if (rowCount >= tabPerRow)
                    {
                        rowCount = 0;
                        GUILayout.EndHorizontal();
                        GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                    }
                    rowCount++;

                    bool   focused = i == TargetTabID;
                    string color   = focused ? "<color=lime>" : "<color=orange>";
                    GUI.color = focused ? Color.green : Color.white;

                    if (GUILayout.Button(color + window.Title + "</color>", new GUILayoutOption[] { GUILayout.Width(200) }))
                    {
                        TargetTabID = i;
                    }
                    if (GUILayout.Button("<color=red><b>X</b></color>", new GUILayoutOption[] { GUILayout.Width(22) }))
                    {
                        window.DestroyWindow();
                    }
                }
                GUI.color = Color.white;
                GUILayout.EndHorizontal();
                GUILayout.EndVertical();
                GUI.skin.button.alignment = TextAnchor.MiddleCenter;

                m_targetWindow.WindowFunction(m_targetWindow.windowID);

                m_rect = ResizeDrag.ResizeWindow(m_rect, windowID);

                GUIHelper.EndArea();
            }
            catch (Exception e)
            {
                if (!e.Message.Contains("in a group with only"))
                {
                    ExplorerCore.Log("Exception drawing Tab View window: " + e.GetType() + ", " + e.Message);
                    ExplorerCore.Log(e.StackTrace);
                }
            }
        }
Exemple #19
0
        private void DrawBitwise()
        {
            if (OwnerCacheObject.CanWrite)
            {
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

                GUI.skin.label.alignment = TextAnchor.MiddleRight;
                GUILayout.Label("RHS:", new GUILayoutOption[] { GUILayout.Width(35) });
                GUI.skin.label.alignment = TextAnchor.UpperLeft;

                if (GUILayout.Button("~", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    if (int.TryParse(m_bitwiseOperatorInput, out int bit))
                    {
                        Value = ~bit;
                        RefreshToString();
                    }
                }

                if (GUILayout.Button("<<", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    if (int.TryParse(m_bitwiseOperatorInput, out int bit))
                    {
                        Value = (int)Value << bit;
                        RefreshToString();
                    }
                }
                if (GUILayout.Button(">>", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    if (int.TryParse(m_bitwiseOperatorInput, out int bit))
                    {
                        Value = (int)Value >> bit;
                        RefreshToString();
                    }
                }
                if (GUILayout.Button("|", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    if (int.TryParse(m_bitwiseOperatorInput, out int bit))
                    {
                        Value = (int)Value | bit;
                        RefreshToString();
                    }
                }
                if (GUILayout.Button("&", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    if (int.TryParse(m_bitwiseOperatorInput, out int bit))
                    {
                        Value = (int)Value & bit;
                        RefreshToString();
                    }
                }
                if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
                {
                    if (int.TryParse(m_bitwiseOperatorInput, out int bit))
                    {
                        Value = (int)Value ^ bit;
                        RefreshToString();
                    }
                }

                m_bitwiseOperatorInput = GUIHelper.TextField(m_bitwiseOperatorInput, new GUILayoutOption[] { GUILayout.Width(55) });

                GUILayout.EndHorizontal();
            }

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"<color=cyan>Binary:</color>", new GUILayoutOption[] { GUILayout.Width(60) });
            m_binaryInput = GUIHelper.TextField(m_binaryInput, new GUILayoutOption[0]);
            if (OwnerCacheObject.CanWrite)
            {
                if (GUILayout.Button("Apply", new GUILayoutOption[0]))
                {
                    SetValueFromBinaryInput();
                }
            }
            GUILayout.EndHorizontal();
        }
Exemple #20
0
        public override void DrawValue(Rect window, float width)
        {
            if (OwnerCacheObject.CanWrite)
            {
                if (!IsExpanded)
                {
                    if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = true;
                    }
                }
                else
                {
                    if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = false;
                    }
                }
            }

            GUILayout.Label($"<color=#2df7b2>Vector{VectorSize}</color>: {(string)ToStringMethod.Invoke(Value, new object[0])}", new GUILayoutOption[0]);

            if (OwnerCacheObject.CanWrite && IsExpanded)
            {
                GUILayout.EndHorizontal();

                var whitespace = CalcWhitespace(window);

                // always draw x and y
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) });
                x = GUIHelper.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) });
                y = GUIHelper.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                if (VectorSize > 2)
                {
                    // draw z
                    GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                    GUIHelper.Space(whitespace);
                    GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) });
                    z = GUIHelper.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) });
                    GUILayout.EndHorizontal();
                }
                if (VectorSize > 3)
                {
                    // draw w
                    GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                    GUIHelper.Space(whitespace);
                    GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) });
                    w = GUIHelper.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) });
                    GUILayout.EndHorizontal();
                }

                // draw set value button
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
                {
                    SetValueFromInput();
                }
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            }
        }
Exemple #21
0
        private void SearchBox()
        {
            GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, null);

            // ----- GameObject Search -----
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("<b><color=orange>Search</color></b>", new GUILayoutOption[0]);
            GUI.skin.label.alignment = TextAnchor.UpperLeft;

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

            GUILayout.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) });
            m_searchInput = GUIHelper.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) });

            GUILayout.Label("Max Results:", new GUILayoutOption[] { GUILayout.Width(100) });
            var s = MaxSearchResults.ToString();

            s = GUIHelper.TextField(s, new GUILayoutOption[] { GUILayout.Width(80) });
            if (int.TryParse(s, out int i))
            {
                MaxSearchResults = i;
            }
            GUILayout.EndHorizontal();

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);

            GUILayout.Label("Class Filter:", new GUILayoutOption[] { GUILayout.Width(100) });
            ClassFilterToggle(TypeFilter.Object, "Object");
            ClassFilterToggle(TypeFilter.GameObject, "GameObject");
            ClassFilterToggle(TypeFilter.Component, "Component");
            ClassFilterToggle(TypeFilter.Custom, "Custom");
            GUILayout.EndHorizontal();
            if (TypeMode == TypeFilter.Custom)
            {
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUI.skin.label.alignment = TextAnchor.MiddleRight;
                GUILayout.Label("Custom Class:", new GUILayoutOption[] { GUILayout.Width(250) });
                GUI.skin.label.alignment = TextAnchor.UpperLeft;
                m_typeInput = GUIHelper.TextField(m_typeInput, new GUILayoutOption[] { GUILayout.Width(250) });
                GUILayout.EndHorizontal();
            }

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label("Scene Filter:", new GUILayoutOption[] { GUILayout.Width(100) });
            SceneFilterToggle(SceneFilter.Any, "Any", 60);
            SceneFilterToggle(SceneFilter.This, "This Scene", 100);
            SceneFilterToggle(SceneFilter.DontDestroy, "DontDestroyOnLoad", 140);
            SceneFilterToggle(SceneFilter.None, "No Scene", 80);
            GUILayout.EndHorizontal();

            if (GUILayout.Button("<b><color=cyan>Search</color></b>", new GUILayoutOption[0]))
            {
                Search();
            }
            //if (m_cachingResults)
            //{
            //    GUILayout.Label("Searching...", new GUILayoutOption[0]);
            //}
            //else
            //{
            //    if (GUILayout.Button("<b><color=cyan>Search</color></b>", new GUILayoutOption[0]))
            //    {
            //        Search();
            //    }
            //}

            GUILayout.EndVertical();
        }
Exemple #22
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 #23
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();
        }
Exemple #24
0
        public override void DrawWindow()
        {
            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("<color=orange><size=16><b>Options</b></size></color>", new GUILayoutOption[0]);
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;

            GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[0]);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Menu Toggle Key:", new GUILayoutOption[] { GUILayout.Width(215f) });
            toggleKeyInput.IValue.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
            GUILayout.EndHorizontal();

            UIStyles.HorizontalLine(Color.black, true);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Default Window Size:", new GUILayoutOption[] { GUILayout.Width(215f) });
            defaultSizeInput.IValue.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
            GUILayout.EndHorizontal();

            UIStyles.HorizontalLine(Color.black, true);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Default Items per Page:", new GUILayoutOption[] { GUILayout.Width(215f) });
            defaultPageLimitInput.IValue.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
            GUILayout.EndHorizontal();

            UIStyles.HorizontalLine(Color.black, true);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Enable Bitwise Editing:", new GUILayoutOption[] { GUILayout.Width(215f) });
            bitwiseSupportInput.IValue.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
            GUILayout.EndHorizontal();

            UIStyles.HorizontalLine(Color.black, true);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Enable Tab View:", new GUILayoutOption[] { GUILayout.Width(215f) });
            tabViewInput.IValue.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
            GUILayout.EndHorizontal();

            UIStyles.HorizontalLine(Color.black, true);

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUILayout.Label($"Default Output Path:", new GUILayoutOption[] { GUILayout.Width(215f) });
            defaultOutputPathInput.IValue.DrawValue(MainMenu.MainRect, MainMenu.MainRect.width - 215f);
            GUILayout.EndHorizontal();

            if (GUILayout.Button("<color=lime><b>Apply and Save</b></color>", new GUILayoutOption[0]))
            {
                ApplyAndSave();
            }

            GUILayout.EndVertical();

            GUIHelper.Space(10f);

            GUI.skin.label.alignment = TextAnchor.MiddleCenter;
            GUILayout.Label("<color=orange><size=16><b>Other</b></size></color>", new GUILayoutOption[0]);
            GUI.skin.label.alignment = TextAnchor.MiddleLeft;

            GUIHelper.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[0]);

            if (GUILayout.Button("Inspect Test Class", new GUILayoutOption[0]))
            {
                WindowManager.InspectObject(Tests.TestClass.Instance, out bool _);
            }

            GUILayout.EndVertical();
        }
Exemple #25
0
        public override void DrawValue(Rect window, float width)
        {
            if (OwnerCacheObject.CanWrite)
            {
                if (!IsExpanded)
                {
                    if (GUILayout.Button("v", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = true;
                    }
                }
                else
                {
                    if (GUILayout.Button("^", new GUILayoutOption[] { GUILayout.Width(25) }))
                    {
                        IsExpanded = false;
                    }
                }
            }

            //var c = (Color)Value;
            //GUI.color = c;
            GUILayout.Label($"<color=#2df7b2>Color:</color> {((Color)Value).ToString()}", new GUILayoutOption[0]);
            //GUI.color = Color.white;

            if (OwnerCacheObject.CanWrite && IsExpanded)
            {
                GUILayout.EndHorizontal();

                var whitespace = CalcWhitespace(window);

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) });
                r = GUIHelper.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) });
                g = GUIHelper.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) });
                b = GUIHelper.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) });
                a = GUIHelper.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) });
                GUILayout.EndHorizontal();

                // draw set value button
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(whitespace);
                if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) }))
                {
                    SetValueFromInput();
                }
                GUILayout.EndHorizontal();

                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            }
        }
Exemple #26
0
        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();
        }
Exemple #27
0
        public static void GameObjectButton(object _obj, Action <Transform> inspectOverride = null, bool showSmallInspect = true, float width = 380)
        {
            var go = (_obj as GameObject) ?? (_obj as Transform).gameObject;

            if (!go)
            {
                return;
            }

            bool hasChild = go.transform.childCount > 0;

            string label = hasChild ? $"[{go.transform.childCount} children] " : "";

            label += go.name;

            bool  enabled    = go.activeSelf;
            int   childCount = go.transform.childCount;
            Color color;

            if (enabled)
            {
                if (childCount > 0)
                {
                    color = Color.green;
                }
                else
                {
                    color = UIStyles.LightGreen;
                }
            }
            else
            {
                color = Color.red;
            }

            // ------ toggle active button ------

            GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
            GUI.skin.button.alignment = TextAnchor.UpperLeft;

            GUI.color = color;

            enabled = GUILayout.Toggle(enabled, "", new GUILayoutOption[] { GUILayout.Width(18) });
            if (go.activeSelf != enabled)
            {
                go.SetActive(enabled);
            }

            // ------- actual button ---------

            if (GUILayout.Button(label, new GUILayoutOption[] { GUILayout.Height(22), GUILayout.Width(width) }))
            {
                if (inspectOverride != null)
                {
                    inspectOverride(go.transform);
                }
                else
                {
                    WindowManager.InspectObject(_obj, out bool _);
                }
            }

            // ------ small "Inspect" button on the right ------

            GUI.skin.button.alignment = TextAnchor.MiddleCenter;
            GUI.color = Color.white;

            if (showSmallInspect)
            {
                InspectButton(_obj);
            }

            GUILayout.EndHorizontal();
        }
Exemple #28
0
        public void Draw(Rect window, float labelWidth = 215f)
        {
            if (labelWidth > 0)
            {
                ClampLabelWidth(window, ref labelWidth);
            }

            var cacheMember = OwnerCacheObject as CacheMember;

            if (cacheMember != null && cacheMember.MemInfo != null)
            {
                GUILayout.Label(cacheMember.RichTextName, new GUILayoutOption[] { GUILayout.Width(labelWidth) });
            }
            else
            {
                GUIHelper.Space(labelWidth);
            }

            var cacheMethod = OwnerCacheObject as CacheMethod;

            if (cacheMember != null && cacheMember.HasParameters)
            {
                GUIHelper.BeginVertical(new GUILayoutOption[] { GUILayout.ExpandHeight(true) });

                if (cacheMember.m_isEvaluating)
                {
                    if (cacheMethod != null && cacheMethod.GenericArgs.Length > 0)
                    {
                        cacheMethod.DrawGenericArgsInput();
                    }

                    if (cacheMember.m_arguments.Length > 0)
                    {
                        cacheMember.DrawArgsInput();
                    }

                    GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                    if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
                    {
                        if (cacheMethod != null)
                        {
                            cacheMethod.Evaluate();
                        }
                        else
                        {
                            cacheMember.UpdateValue();
                        }
                    }
                    if (GUILayout.Button("Cancel", new GUILayoutOption[] { GUILayout.Width(70) }))
                    {
                        cacheMember.m_isEvaluating = false;
                    }
                    GUILayout.EndHorizontal();
                }
                else
                {
                    var lbl = $"Evaluate (";
                    int len = cacheMember.m_arguments.Length;
                    if (cacheMethod != null)
                    {
                        len += cacheMethod.GenericArgs.Length;
                    }
                    lbl += len + " params)";

                    if (GUILayout.Button(lbl, new GUILayoutOption[] { GUILayout.Width(150) }))
                    {
                        cacheMember.m_isEvaluating = true;
                    }
                }

                GUILayout.EndVertical();

                GUILayout.EndHorizontal();
                GUIHelper.BeginHorizontal(new GUILayoutOption[0]);
                GUIHelper.Space(labelWidth);
            }
            else if (cacheMethod != null)
            {
                if (GUILayout.Button(EVALUATE_LABEL, new GUILayoutOption[] { GUILayout.Width(70) }))
                {
                    cacheMethod.Evaluate();
                }

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

            string typeName = $"<color={Syntax.Class_Instance}>{ValueType.FullName}</color>";

            if (cacheMember != null && !string.IsNullOrEmpty(cacheMember.ReflectionException))
            {
                GUILayout.Label("<color=red>Reflection failed!</color> (" + cacheMember.ReflectionException + ")", new GUILayoutOption[0]);
            }
            else if (cacheMember != null && (cacheMember.HasParameters || cacheMember is CacheMethod) && !cacheMember.m_evaluated)
            {
                GUILayout.Label($"<color=grey><i>Not yet evaluated</i></color> ({typeName})", new GUILayoutOption[0]);
            }
            else if ((Value == null || Value is UnityEngine.Object uObj && !uObj) && !(cacheMember is CacheMethod))
            {
                GUILayout.Label($"<i>null ({typeName})</i>", new GUILayoutOption[0]);
            }
Exemple #29
0
        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);
            }
        }