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>"; } GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUI.skin.label.alignment = TextAnchor.MiddleCenter; GUILayout.Label(i.ToString(), new GUILayoutOption[] { GUILayout.Width(15) }); GUILayout.Label(label, new GUILayoutOption[] { GUILayout.ExpandWidth(false) }); this.m_argumentInput[i] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.ExpandWidth(true) }); GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUILayout.EndHorizontal(); } }
private void DrawHeaderArea() { GUIUnstrip.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 ----- GUIUnstrip.BeginHorizontal(GUIContent.none, GUI.skin.box, null); GUILayout.Label("<b>Search Scene:</b>", new GUILayoutOption[] { GUILayout.Width(100) }); m_searchInput = GUIUnstrip.TextField(m_searchInput, new GUILayoutOption[0]); if (GUILayout.Button("Search", new GUILayoutOption[] { GUILayout.Width(80) })) { Search(); } GUILayout.EndHorizontal(); GUIUnstrip.Space(5); }
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); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); z = GUIUnstrip.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); // draw set value button GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); } }
private Vector3 TranslateControl(TranslateType mode, ref float amount, bool multByTime) { GUIUnstrip.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]; GUIUnstrip.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 = GUIUnstrip.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); }
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]; GUIUnstrip.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] = GUIUnstrip.TextField(input, new GUILayoutOption[] { GUILayout.Width(150) }); GUI.skin.label.alignment = TextAnchor.MiddleLeft; GUILayout.Label(types, new GUILayoutOption[0]); GUILayout.EndHorizontal(); } }
private void SearchBox() { GUIUnstrip.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; GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("Name Contains:", new GUILayoutOption[] { GUILayout.Width(100) }); m_searchInput = GUIUnstrip.TextField(m_searchInput, new GUILayoutOption[] { GUILayout.Width(200) }); GUILayout.EndHorizontal(); GUIUnstrip.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) { GUIUnstrip.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 = GUIUnstrip.TextField(m_typeInput, new GUILayoutOption[] { GUILayout.Width(250) }); GUILayout.EndHorizontal(); } GUIUnstrip.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(); } GUILayout.EndVertical(); }
private void PlusMinusFloat(ref float f, float amount, bool multByTime) { string s = f.ToString("F3"); s = GUIUnstrip.TextField(s, new GUILayoutOption[] { GUILayout.Width(60) }); if (float.TryParse(s, out float f2)) { f = f2; } if (GUIUnstrip.RepeatButton("-", new GUILayoutOption[] { GUILayout.Width(20) })) { f -= multByTime ? amount * Time.deltaTime : amount; } if (GUIUnstrip.RepeatButton("+", new GUILayoutOption[] { GUILayout.Width(20) })) { f += multByTime ? amount * Time.deltaTime : amount; } }
private void DrawTextureControls() { GUIUnstrip.BeginHorizontal(); GUILayout.Label("Save folder:", new GUILayoutOption[] { GUILayout.Width(80f) }); saveFolder = GUIUnstrip.TextField(saveFolder, new GUILayoutOption[0]); GUIUnstrip.Space(10f); GUILayout.EndHorizontal(); if (GUILayout.Button("Save to PNG", new GUILayoutOption[] { GUILayout.Width(100f) })) { if (currentTex) { var name = RemoveInvalidFilenameChars(currentTex.name ?? ""); if (string.IsNullOrEmpty(name)) { if (OwnerCacheObject is CacheMember cacheMember) { name = cacheMember.MemInfo.Name; } else { name = "UNTITLED"; } } SaveTextureAsPNG(currentTex, saveFolder, name, false); ExplorerCore.Log($@"Saved to {saveFolder}\{name}.png!"); } else { ExplorerCore.Log("Cannot save a null texture!"); } } }
private void DrawBitwise() { if (OwnerCacheObject.CanWrite) { GUIUnstrip.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 = GUIUnstrip.TextField(m_bitwiseOperatorInput, new GUILayoutOption[] { GUILayout.Width(55) }); GUILayout.EndHorizontal(); } GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label($"<color=cyan>Binary:</color>", new GUILayoutOption[] { GUILayout.Width(60) }); m_binaryInput = GUIUnstrip.TextField(m_binaryInput, new GUILayoutOption[0]); if (OwnerCacheObject.CanWrite) { if (GUILayout.Button("Apply", new GUILayoutOption[0])) { SetValueFromBinaryInput(); } } 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; } } } //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); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("R:", new GUILayoutOption[] { GUILayout.Width(30) }); r = GUIUnstrip.TextField(r, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("G:", new GUILayoutOption[] { GUILayout.Width(30) }); g = GUIUnstrip.TextField(g, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("B:", new GUILayoutOption[] { GUILayout.Width(30) }); b = GUIUnstrip.TextField(b, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("A:", new GUILayoutOption[] { GUILayout.Width(30) }); a = GUIUnstrip.TextField(a, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); // draw set value button GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); } }
// =========== GUI DRAW =========== // public override void WindowFunction(int windowID) { try { // ====== HEADER ====== 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); } var asInstance = this as InstanceInspector; GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); var labelWidth = (asInstance != null && asInstance.m_uObj) ? new GUILayoutOption[] { GUILayout.Width(245f) } : new GUILayoutOption[0]; GUILayout.Label("<b>Type:</b> <color=cyan>" + TargetType.FullName + "</color>", labelWidth); if (asInstance != null) { asInstance.DrawInstanceControls(rect); } else { GUILayout.EndHorizontal(); } UIStyles.HorizontalLine(Color.grey); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("<b>Search:</b>", new GUILayoutOption[] { GUILayout.Width(75) }); m_search = GUIUnstrip.TextField(m_search, new GUILayoutOption[0]); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("<b>Filter:</b>", new GUILayoutOption[] { GUILayout.Width(75) }); FilterTypeToggle(MemberTypes.All, "All"); FilterTypeToggle(MemberTypes.Property, "Properties"); FilterTypeToggle(MemberTypes.Field, "Fields"); FilterTypeToggle(MemberTypes.Method, "Methods"); GUILayout.EndHorizontal(); if (this is InstanceInspector) { GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("<b>Scope:</b>", new GUILayoutOption[] { GUILayout.Width(75) }); FilterScopeToggle(MemberScopes.Both, "Both"); FilterScopeToggle(MemberScopes.Instance, "Instance"); FilterScopeToggle(MemberScopes.Static, "Static"); GUILayout.EndHorizontal(); } GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUILayout.Label("<b>Values:</b>", new GUILayoutOption[] { GUILayout.Width(75) }); if (GUILayout.Button("Update", new GUILayoutOption[] { GUILayout.Width(100) })) { UpdateValues(); } GUI.color = m_autoUpdate ? Color.green : Color.red; m_autoUpdate = GUILayout.Toggle(m_autoUpdate, "Auto-update?", new GUILayoutOption[] { GUILayout.Width(100) }); GUI.color = m_hideFailedReflection ? Color.green : Color.red; m_hideFailedReflection = GUILayout.Toggle(m_hideFailedReflection, "Hide failed Reflection?", new GUILayoutOption[] { GUILayout.Width(150) }); GUI.color = Color.white; GUILayout.EndHorizontal(); GUIUnstrip.Space(10); Pages.ItemCount = m_cachedMembersFiltered.Length; // prev/next page buttons GUIUnstrip.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); } Pages.CurrentPageLabel(); if (GUILayout.Button("Next >", new GUILayoutOption[] { GUILayout.Width(80) })) { Pages.TurnPage(Turn.Right, ref this.scroll); } } GUILayout.EndHorizontal(); // ====== BODY ====== scroll = GUIUnstrip.BeginScrollView(scroll); GUIUnstrip.Space(10); UIStyles.HorizontalLine(Color.grey); GUIUnstrip.BeginVertical(GUIContent.none, GUI.skin.box, null); var members = this.m_cachedMembersFiltered; int start = Pages.CalculateOffsetIndex(); for (int j = start; (j < start + Pages.ItemsPerPage && j < members.Length); j++) { var holder = members[j]; GUIUnstrip.BeginHorizontal(new GUILayoutOption[] { GUILayout.Height(25) }); try { holder.Draw(rect, 180f); } catch { GUILayout.EndHorizontal(); continue; } GUILayout.EndHorizontal(); // if not last element if (!(j == (start + Pages.ItemsPerPage - 1) || j == (members.Length - 1))) { UIStyles.HorizontalLine(new Color(0.07f, 0.07f, 0.07f), true); } } GUILayout.EndVertical(); GUIUnstrip.EndScrollView(); if (!WindowManager.TabView) { m_rect = ResizeDrag.ResizeWindow(rect, windowID); GUIUnstrip.EndArea(); } } catch (Exception e) when(e.Message.Contains("in a group with only")) { // suppress } catch (Exception e) { ExplorerCore.LogWarning("Exception drawing ReflectionWindow: " + e.GetType() + ", " + e.Message); DestroyWindow(); return; } }
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 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 GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("X:", new GUILayoutOption[] { GUILayout.Width(30) }); x = GUIUnstrip.TextField(x, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("Y:", new GUILayoutOption[] { GUILayout.Width(30) }); y = GUIUnstrip.TextField(y, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); if (VectorSize > 2) { // draw z GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("Z:", new GUILayoutOption[] { GUILayout.Width(30) }); z = GUIUnstrip.TextField(z, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); } if (VectorSize > 3) { // draw w GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); GUILayout.Label("W:", new GUILayoutOption[] { GUILayout.Width(30) }); w = GUIUnstrip.TextField(w, new GUILayoutOption[] { GUILayout.Width(120) }); GUILayout.EndHorizontal(); } // draw set value button GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUIUnstrip.Space(whitespace); if (GUILayout.Button("<color=lime>Apply</color>", new GUILayoutOption[] { GUILayout.Width(155) })) { SetValueFromInput(); } GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); } }
private void GameObjectControls() { if (m_hideControls) { GUIUnstrip.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; } GUIUnstrip.BeginVertical(GUIContent.none, GUI.skin.box, new GUILayoutOption[] { GUILayout.Width(520) }); GUIUnstrip.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(); GUIUnstrip.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(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); m_setParentInput = GUIUnstrip.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(); GUIUnstrip.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); GUIUnstrip.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(); GUIUnstrip.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(); }
private void ComponentList(Rect m_rect) { GUIUnstrip.BeginVertical(GUIContent.none, GUI.skin.box, null); m_compScroll = GUIUnstrip.BeginScrollView(m_compScroll); GUILayout.Label("<b><size=15>Components</size></b>", new GUILayoutOption[0]); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); CompPages.DrawLimitInputArea(); if (CompPages.ItemCount > CompPages.ItemsPerPage) { CompPages.CurrentPageLabel(); GUILayout.EndHorizontal(); GUIUnstrip.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(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); var width = m_rect.width / 2 - 135f; m_addComponentInput = GUIUnstrip.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 GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); if (ReflectionHelpers.BehaviourType.IsAssignableFrom(type)) { #if CPP BehaviourEnabledBtn(component.TryCast <Behaviour>()); #else BehaviourEnabledBtn(component as Behaviour); #endif } else { GUIUnstrip.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); } } GUIUnstrip.EndScrollView(); GUILayout.EndVertical(); }