private void MainWindow(int id) { GUI.DragWindow(new Rect(0, 0, MainRect.width - 90, 20)); if (GUIHelper.Button(new Rect(MainRect.width - 90, 2, 80, 20), $"Hide ({ModConfig.Instance.Main_Menu_Toggle})")) { ExplorerCore.ShowMenu = false; return; } GUIHelper.BeginArea(new Rect(5, 25, MainRect.width - 10, MainRect.height - 35), GUI.skin.box); MainHeader(); var page = Pages[m_currentPage]; page.scroll = GUIHelper.BeginScrollView(page.scroll); page.DrawWindow(); GUIHelper.EndScrollView(); MainRect = ResizeDrag.ResizeWindow(MainRect, MainWindowID); GUIHelper.EndArea(); }
// =========== 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 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); } }
public override void WindowFunction(int windowID) { try { GUI.DragWindow(new Rect(0, 0, m_rect.width - 90, 20)); if (GUIUnstrip.Button(new Rect(m_rect.width - 90, 2, 80, 20), "<color=red>Close All</color>")) { foreach (var window in WindowManager.Windows) { window.DestroyWindow(); } return; } GUIUnstrip.BeginArea(new Rect(5, 25, m_rect.width - 10, m_rect.height - 35), GUI.skin.box); GUIUnstrip.BeginVertical(GUIContent.none, GUI.skin.box, null); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); GUI.skin.button.alignment = TextAnchor.MiddleLeft; int tabPerRow = Mathf.FloorToInt((float)((decimal)m_rect.width / 238)); int rowCount = 0; for (int i = 0; i < WindowManager.Windows.Count; i++) { if (rowCount >= tabPerRow) { rowCount = 0; GUILayout.EndHorizontal(); GUIUnstrip.BeginHorizontal(new GUILayoutOption[0]); } rowCount++; bool focused = i == TargetTabID; string color = focused ? "<color=lime>" : "<color=orange>"; GUI.color = focused ? Color.green : Color.white; var window = WindowManager.Windows[i]; 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); GUIUnstrip.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); } } }