2022-04-12 05:20:35 +10:00
|
|
|
|
using UnityEngine;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
using UnityEngine.UI;
|
2021-06-30 07:49:58 +10:00
|
|
|
|
using UnityExplorer.Inspectors;
|
2021-12-02 18:35:46 +11:00
|
|
|
|
using UniverseLib.UI;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
|
|
|
|
namespace UnityExplorer.UI.Panels
|
|
|
|
|
{
|
2022-04-14 01:25:59 +10:00
|
|
|
|
public class InspectorPanel : UEPanel
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
|
|
|
|
public static InspectorPanel Instance { get; private set; }
|
|
|
|
|
|
|
|
|
|
public override string Name => "Inspector";
|
|
|
|
|
public override UIManager.Panels PanelType => UIManager.Panels.Inspector;
|
|
|
|
|
public override bool ShouldSaveActiveState => false;
|
2022-04-14 01:25:59 +10:00
|
|
|
|
|
2021-05-17 18:47:37 +10:00
|
|
|
|
public override int MinWidth => 810;
|
2021-05-05 21:27:09 +10:00
|
|
|
|
public override int MinHeight => 350;
|
2022-04-14 01:25:59 +10:00
|
|
|
|
public override Vector2 DefaultAnchorMin => new(0.35f, 0.175f);
|
|
|
|
|
public override Vector2 DefaultAnchorMax => new(0.8f, 0.925f);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
|
|
|
|
public GameObject NavbarHolder;
|
2022-01-17 21:00:55 +11:00
|
|
|
|
public Dropdown MouseInspectDropdown;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
public GameObject ContentHolder;
|
2021-04-27 21:22:48 +10:00
|
|
|
|
public RectTransform ContentRect;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-05-18 19:55:27 +10:00
|
|
|
|
public static float CurrentPanelWidth => Instance.Rect.rect.width;
|
|
|
|
|
public static float CurrentPanelHeight => Instance.Rect.rect.height;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
public InspectorPanel(UIBase owner) : base(owner)
|
|
|
|
|
{
|
|
|
|
|
Instance = this;
|
|
|
|
|
}
|
|
|
|
|
|
2021-04-25 00:21:12 +10:00
|
|
|
|
public override void Update()
|
|
|
|
|
{
|
|
|
|
|
InspectorManager.Update();
|
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
public override void OnFinishResize()
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2022-04-14 01:25:59 +10:00
|
|
|
|
base.OnFinishResize();
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-05-18 19:55:27 +10:00
|
|
|
|
InspectorManager.PanelWidth = this.Rect.rect.width;
|
2022-04-14 01:25:59 +10:00
|
|
|
|
InspectorManager.OnPanelResized(Rect.rect.width);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
protected override void ConstructPanelContent()
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2022-04-12 05:20:35 +10:00
|
|
|
|
GameObject closeHolder = this.TitleBar.transform.Find("CloseHolder").gameObject;
|
2022-01-17 21:00:55 +11:00
|
|
|
|
|
|
|
|
|
// Inspect under mouse dropdown on title bar
|
|
|
|
|
|
2022-04-12 05:20:35 +10:00
|
|
|
|
GameObject mouseDropdown = UIFactory.CreateDropdown(closeHolder, "MouseInspectDropdown", out MouseInspectDropdown, "Mouse Inspect", 14,
|
2022-03-04 00:20:04 +11:00
|
|
|
|
MouseInspector.OnDropdownSelect);
|
2022-01-17 21:00:55 +11:00
|
|
|
|
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);
|
|
|
|
|
|
2021-05-16 21:46:38 +10:00
|
|
|
|
// add close all button to titlebar
|
|
|
|
|
|
2022-04-12 05:20:35 +10:00
|
|
|
|
UniverseLib.UI.Models.ButtonRef closeAllBtn = UIFactory.CreateButton(closeHolder.gameObject, "CloseAllBtn", "Close All",
|
2021-05-16 21:46:38 +10:00
|
|
|
|
new Color(0.3f, 0.2f, 0.2f));
|
|
|
|
|
UIFactory.SetLayoutElement(closeAllBtn.Component.gameObject, minHeight: 25, minWidth: 80);
|
|
|
|
|
closeAllBtn.Component.transform.SetSiblingIndex(closeAllBtn.Component.transform.GetSiblingIndex() - 1);
|
|
|
|
|
closeAllBtn.OnClick += InspectorManager.CloseAllTabs;
|
|
|
|
|
|
2021-04-25 00:21:12 +10:00
|
|
|
|
// this.UIRoot.GetComponent<Mask>().enabled = false;
|
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
UIFactory.SetLayoutGroup<VerticalLayoutGroup>(this.ContentRoot, true, true, true, true, 4, padLeft: 5, padRight: 5);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
this.NavbarHolder = UIFactory.CreateGridGroup(this.ContentRoot, "Navbar", new Vector2(200, 22), new Vector2(4, 4),
|
2021-05-05 21:27:09 +10:00
|
|
|
|
new Color(0.05f, 0.05f, 0.05f));
|
2021-04-25 00:21:12 +10:00
|
|
|
|
//UIFactory.SetLayoutElement(NavbarHolder, flexibleWidth: 9999, minHeight: 0, preferredHeight: 0, flexibleHeight: 9999);
|
|
|
|
|
NavbarHolder.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
this.ContentHolder = UIFactory.CreateVerticalGroup(this.ContentRoot, "ContentHolder", true, true, true, true, 0, default,
|
2021-04-25 00:21:12 +10:00
|
|
|
|
new Color(0.1f, 0.1f, 0.1f));
|
|
|
|
|
UIFactory.SetLayoutElement(ContentHolder, flexibleHeight: 9999);
|
2021-04-27 21:22:48 +10:00
|
|
|
|
ContentRect = ContentHolder.GetComponent<RectTransform>();
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2022-04-14 01:25:59 +10:00
|
|
|
|
this.SetActive(false);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
2021-04-25 21:20:50 +10:00
|
|
|
|
}
|