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) { b = GUILayout.Toggle(b, label, new GUILayoutOption[0]); if (b != (bool)Value) { Value = b; OwnerCacheObject.SetValue(); } } else { GUILayout.Label(label, new GUILayoutOption[0]); } return; } // all other non-bool values use TextField GUIUnstrip.BeginVertical(new GUILayoutOption[0]); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("<color=#2df7b2><i>" + ValueType.Name + "</i></color>", new GUILayoutOption[] { GUILayout.Width(50) }); m_valueToString = GUIUnstrip.TextArea(m_valueToString, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); if (OwnerCacheObject.CanWrite) { if (GUILayout.Button("<color=#00FF00>Apply</color>", new GUILayoutOption[] { GUILayout.Width(60) })) { SetValueFromInput(); } } if (ModConfig.Instance.Bitwise_Support && m_canBitwiseOperate) { m_inBitwiseMode = GUILayout.Toggle(m_inBitwiseMode, "Bitwise?", new GUILayoutOption[0]); } GUIUnstrip.Space(10); GUILayout.EndHorizontal(); if (ModConfig.Instance.Bitwise_Support && m_inBitwiseMode) { DrawBitwise(); } GUILayout.EndVertical(); }
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 = GUIUnstrip.BeginScrollView( inputAreaScroll, new GUILayoutOption[] { GUILayout.Height(250), GUILayout.ExpandHeight(true) } ); GUI.SetNextControlName(INPUT_CONTROL_NAME); m_input = GUIUnstrip.TextArea(m_input, new GUILayoutOption[] { GUILayout.ExpandHeight(true) }); GUIUnstrip.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 = GUIUnstrip.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; GUIUnstrip.EndScrollView(); } if (shouldRefocus) { GUI.FocusControl(INPUT_CONTROL_NAME); shouldRefocus = false; } // USING DIRECTIVES GUILayout.Label("<b>Using directives:</b>", new GUILayoutOption[0]); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Add namespace:", new GUILayoutOption[] { GUILayout.Width(105) }); m_usingInput = GUIUnstrip.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(); }
public override void WindowFunction(int windowID) { try { var rect = WindowManager.TabView ? TabViewWindow.Instance.m_rect : this.m_rect; if (!WindowManager.TabView) { Header(); GUIUnstrip.BeginArea(new Rect(5, 25, rect.width - 10, rect.height - 35), GUI.skin.box); } scroll = GUIUnstrip.BeginScrollView(scroll); GUIUnstrip.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(); GUIUnstrip.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); } } GUIUnstrip.TextArea(pathlabel, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Name:", new GUILayoutOption[] { GUILayout.Width(50) }); GUIUnstrip.TextArea(m_name, new GUILayoutOption[0]); GUILayout.EndHorizontal(); // --- Horizontal Columns section --- GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) }); TransformList(rect); GUILayout.EndVertical(); GUIUnstrip.BeginVertical(new GUILayoutOption[] { GUILayout.Width(rect.width / 2 - 17) }); ComponentList(rect); GUILayout.EndVertical(); GUILayout.EndHorizontal(); // end horiz columns GameObjectControls(); GUIUnstrip.EndScrollView(); if (!WindowManager.TabView) { m_rect = ResizeDrag.ResizeWindow(rect, windowID); GUIUnstrip.EndArea(); } } catch (Exception e) { DestroyOnException(e); } }