Move MouseInspector dropdown to Inspector panel

This commit is contained in:
Sinai
2022-01-17 21:00:55 +11:00
parent aae248bf69
commit c79223f537
3 changed files with 19 additions and 14 deletions

View File

@ -77,7 +77,7 @@ namespace UnityExplorer.Inspectors
case 1: Instance.StartInspect(MouseInspectMode.World); break; case 1: Instance.StartInspect(MouseInspectMode.World); break;
case 2: Instance.StartInspect(MouseInspectMode.UI); break; case 2: Instance.StartInspect(MouseInspectMode.UI); break;
} }
UIManager.MouseInspectDropdown.value = 0; InspectorPanel.Instance.MouseInspectDropdown.value = 0;
} }
public void StartInspect(MouseInspectMode mode) public void StartInspect(MouseInspectMode mode)
@ -111,7 +111,7 @@ namespace UnityExplorer.Inspectors
UIManager.NavBarRect.gameObject.SetActive(true); UIManager.NavBarRect.gameObject.SetActive(true);
UIManager.PanelHolder.SetActive(true); UIManager.PanelHolder.SetActive(true);
var drop = UIManager.MouseInspectDropdown; var drop = InspectorPanel.Instance.MouseInspectDropdown;
if (drop.transform.Find("Dropdown List") is Transform list) if (drop.transform.Find("Dropdown List") is Transform list)
drop.DestroyDropdownList(list.gameObject); drop.DestroyDropdownList(list.gameObject);

View File

@ -24,6 +24,7 @@ namespace UnityExplorer.UI.Panels
public override int MinHeight => 350; public override int MinHeight => 350;
public GameObject NavbarHolder; public GameObject NavbarHolder;
public Dropdown MouseInspectDropdown;
public GameObject ContentHolder; public GameObject ContentHolder;
public RectTransform ContentRect; public RectTransform ContentRect;
@ -60,9 +61,21 @@ namespace UnityExplorer.UI.Panels
public override void ConstructPanelContent() public override void ConstructPanelContent()
{ {
var closeHolder = this.titleBar.transform.Find("CloseHolder").gameObject;
// Inspect under mouse dropdown on title bar
var mouseDropdown = UIFactory.CreateDropdown(closeHolder, out MouseInspectDropdown, "Mouse Inspect", 14,
InspectUnderMouse.OnDropdownSelect);
UIFactory.SetLayoutElement(mouseDropdown, minHeight: 25, minWidth: 140);
MouseInspectDropdown.options.Add(new Dropdown.OptionData("Mouse Inspect"));
MouseInspectDropdown.options.Add(new Dropdown.OptionData("World"));
MouseInspectDropdown.options.Add(new Dropdown.OptionData("UI"));
mouseDropdown.transform.SetSiblingIndex(0);
// add close all button to titlebar // add close all button to titlebar
var closeAllBtn = UIFactory.CreateButton(this.titleBar.transform.Find("CloseHolder").gameObject, "CloseAllBtn", "Close All", var closeAllBtn = UIFactory.CreateButton(closeHolder.gameObject, "CloseAllBtn", "Close All",
new Color(0.3f, 0.2f, 0.2f)); new Color(0.3f, 0.2f, 0.2f));
UIFactory.SetLayoutElement(closeAllBtn.Component.gameObject, minHeight: 25, minWidth: 80); UIFactory.SetLayoutElement(closeAllBtn.Component.gameObject, minHeight: 25, minWidth: 80);
closeAllBtn.Component.transform.SetSiblingIndex(closeAllBtn.Component.transform.GetSiblingIndex() - 1); closeAllBtn.Component.transform.SetSiblingIndex(closeAllBtn.Component.transform.GetSiblingIndex() - 1);

View File

@ -55,7 +55,6 @@ namespace UnityExplorer.UI
public static RectTransform NavBarRect; public static RectTransform NavBarRect;
public static GameObject NavbarTabButtonHolder; public static GameObject NavbarTabButtonHolder;
public static Dropdown MouseInspectDropdown;
private static ButtonRef closeBtn; private static ButtonRef closeBtn;
private static ButtonRef pauseBtn; private static ButtonRef pauseBtn;
@ -84,9 +83,11 @@ namespace UnityExplorer.UI
lastScreenWidth = Screen.width; lastScreenWidth = Screen.width;
lastScreenHeight = Screen.height; lastScreenHeight = Screen.height;
// Create UI // Create UI.
CreatePanelHolder(); CreatePanelHolder();
CreateTopNavBar(); CreateTopNavBar();
// This could be automated with Assembly.GetTypes(),
// but the order is important and I'd have to write something to handle the order.
UIPanels.Add(Panels.AutoCompleter, new AutoCompleteModal()); UIPanels.Add(Panels.AutoCompleter, new AutoCompleteModal());
UIPanels.Add(Panels.ObjectExplorer, new ObjectExplorerPanel()); UIPanels.Add(Panels.ObjectExplorer, new ObjectExplorerPanel());
UIPanels.Add(Panels.Inspector, new InspectorPanel()); UIPanels.Add(Panels.Inspector, new InspectorPanel());
@ -338,15 +339,6 @@ namespace UnityExplorer.UI
UIFactory.SetLayoutElement(pauseBtn.Component.gameObject, minHeight: 25, minWidth: 25); UIFactory.SetLayoutElement(pauseBtn.Component.gameObject, minHeight: 25, minWidth: 25);
pauseBtn.OnClick += OnPauseButtonClicked; pauseBtn.OnClick += OnPauseButtonClicked;
// Inspect under mouse dropdown
var mouseDropdown = UIFactory.CreateDropdown(navbarPanel, out MouseInspectDropdown, "Mouse Inspect", 14,
InspectUnderMouse.OnDropdownSelect);
UIFactory.SetLayoutElement(mouseDropdown, minHeight: 25, minWidth: 140);
MouseInspectDropdown.options.Add(new Dropdown.OptionData("Mouse Inspect"));
MouseInspectDropdown.options.Add(new Dropdown.OptionData("World"));
MouseInspectDropdown.options.Add(new Dropdown.OptionData("UI"));
// Hide menu button // Hide menu button
closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Master_Toggle.Value.ToString()); closeBtn = UIFactory.CreateButton(navbarPanel, "CloseButton", ConfigManager.Master_Toggle.Value.ToString());