2020-10-28 06:39:26 +11:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using System.Text;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
using UnityExplorer.Core.Inspectors;
|
|
|
|
|
using UnityExplorer.UI.Main;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
namespace UnityExplorer.UI.Main.Home
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2021-03-18 17:17:29 +11:00
|
|
|
|
public class InspectorManagerUI
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
public GameObject m_tabBarContent;
|
2020-10-28 07:14:00 +11:00
|
|
|
|
public GameObject m_inspectorContent;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
public void OnSetInspectorTab(InspectorBase inspector)
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
|
|
|
|
Color activeColor = new Color(0, 0.25f, 0, 1);
|
2021-03-18 17:17:29 +11:00
|
|
|
|
ColorBlock colors = inspector.BaseUI.tabButton.colors;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
colors.normalColor = activeColor;
|
|
|
|
|
colors.highlightedColor = activeColor;
|
2021-03-18 17:17:29 +11:00
|
|
|
|
inspector.BaseUI.tabButton.colors = colors;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
public void OnUnsetInspectorTab()
|
2020-10-28 06:39:26 +11:00
|
|
|
|
{
|
2021-03-18 17:17:29 +11:00
|
|
|
|
ColorBlock colors = InspectorManager.Instance.m_activeInspector.BaseUI.tabButton.colors;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
colors.normalColor = new Color(0.2f, 0.2f, 0.2f, 1);
|
|
|
|
|
colors.highlightedColor = new Color(0.1f, 0.3f, 0.1f, 1);
|
2021-03-18 17:17:29 +11:00
|
|
|
|
InspectorManager.Instance.m_activeInspector.BaseUI.tabButton.colors = colors;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public void ConstructInspectorPane()
|
|
|
|
|
{
|
2020-10-28 07:14:00 +11:00
|
|
|
|
var mainObj = UIFactory.CreateVerticalGroup(HomePage.Instance.Content, new Color(72f / 255f, 72f / 255f, 72f / 255f));
|
2020-11-06 20:42:16 +11:00
|
|
|
|
LayoutElement mainLayout = mainObj.AddComponent<LayoutElement>();
|
|
|
|
|
mainLayout.preferredHeight = 400;
|
|
|
|
|
mainLayout.flexibleHeight = 9000;
|
|
|
|
|
mainLayout.preferredWidth = 620;
|
|
|
|
|
mainLayout.flexibleWidth = 9000;
|
|
|
|
|
|
|
|
|
|
var mainGroup = mainObj.GetComponent<VerticalLayoutGroup>();
|
|
|
|
|
mainGroup.childForceExpandHeight = true;
|
|
|
|
|
mainGroup.childForceExpandWidth = true;
|
|
|
|
|
mainGroup.childControlHeight = true;
|
|
|
|
|
mainGroup.childControlWidth = true;
|
2020-11-14 00:46:26 +11:00
|
|
|
|
mainGroup.spacing = 4;
|
2020-11-06 20:42:16 +11:00
|
|
|
|
mainGroup.padding.left = 4;
|
|
|
|
|
mainGroup.padding.right = 4;
|
|
|
|
|
mainGroup.padding.top = 4;
|
|
|
|
|
mainGroup.padding.bottom = 4;
|
|
|
|
|
|
|
|
|
|
var topRowObj = UIFactory.CreateHorizontalGroup(mainObj, new Color(1, 1, 1, 0));
|
|
|
|
|
var topRowGroup = topRowObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
topRowGroup.childForceExpandWidth = false;
|
|
|
|
|
topRowGroup.childControlWidth = true;
|
|
|
|
|
topRowGroup.childForceExpandHeight = true;
|
|
|
|
|
topRowGroup.childControlHeight = true;
|
|
|
|
|
topRowGroup.spacing = 15;
|
|
|
|
|
|
|
|
|
|
var inspectorTitle = UIFactory.CreateLabel(topRowObj, TextAnchor.MiddleLeft);
|
2020-10-28 06:39:26 +11:00
|
|
|
|
Text title = inspectorTitle.GetComponent<Text>();
|
|
|
|
|
title.text = "Inspector";
|
|
|
|
|
title.fontSize = 20;
|
2020-10-28 07:14:00 +11:00
|
|
|
|
var titleLayout = inspectorTitle.AddComponent<LayoutElement>();
|
2020-10-28 06:39:26 +11:00
|
|
|
|
titleLayout.minHeight = 30;
|
|
|
|
|
titleLayout.flexibleHeight = 0;
|
2020-11-06 20:42:16 +11:00
|
|
|
|
titleLayout.minWidth = 90;
|
2020-11-12 20:31:08 +11:00
|
|
|
|
titleLayout.flexibleWidth = 20000;
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
|
|
|
|
ConstructToolbar(topRowObj);
|
|
|
|
|
|
|
|
|
|
// inspector tab bar
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 07:14:00 +11:00
|
|
|
|
m_tabBarContent = UIFactory.CreateGridGroup(mainObj, new Vector2(185, 20), new Vector2(5, 2), new Color(0.1f, 0.1f, 0.1f, 1));
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 07:14:00 +11:00
|
|
|
|
var gridGroup = m_tabBarContent.GetComponent<GridLayoutGroup>();
|
2020-11-14 00:46:26 +11:00
|
|
|
|
gridGroup.padding.top = 3;
|
|
|
|
|
gridGroup.padding.left = 3;
|
|
|
|
|
gridGroup.padding.right = 3;
|
|
|
|
|
gridGroup.padding.bottom = 3;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 07:14:00 +11:00
|
|
|
|
// inspector content area
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
m_inspectorContent = UIFactory.CreateVerticalGroup(mainObj, new Color(0.1f, 0.1f, 0.1f));
|
|
|
|
|
var inspectorGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>();
|
|
|
|
|
inspectorGroup.childForceExpandHeight = true;
|
|
|
|
|
inspectorGroup.childForceExpandWidth = true;
|
|
|
|
|
inspectorGroup.childControlHeight = true;
|
|
|
|
|
inspectorGroup.childControlWidth = true;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
m_inspectorContent = UIFactory.CreateVerticalGroup(mainObj, new Color(0.1f, 0.1f, 0.1f));
|
2020-10-28 07:14:00 +11:00
|
|
|
|
var contentGroup = m_inspectorContent.GetComponent<VerticalLayoutGroup>();
|
|
|
|
|
contentGroup.childForceExpandHeight = true;
|
|
|
|
|
contentGroup.childForceExpandWidth = true;
|
|
|
|
|
contentGroup.childControlHeight = true;
|
|
|
|
|
contentGroup.childControlWidth = true;
|
2020-11-14 00:46:26 +11:00
|
|
|
|
contentGroup.padding.top = 2;
|
|
|
|
|
contentGroup.padding.left = 2;
|
|
|
|
|
contentGroup.padding.right = 2;
|
|
|
|
|
contentGroup.padding.bottom = 2;
|
2020-10-28 06:39:26 +11:00
|
|
|
|
|
2020-10-28 07:14:00 +11:00
|
|
|
|
var contentLayout = m_inspectorContent.AddComponent<LayoutElement>();
|
|
|
|
|
contentLayout.preferredHeight = 900;
|
|
|
|
|
contentLayout.flexibleHeight = 10000;
|
2020-11-06 20:42:16 +11:00
|
|
|
|
contentLayout.preferredWidth = 600;
|
|
|
|
|
contentLayout.flexibleWidth = 10000;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private static void ConstructToolbar(GameObject topRowObj)
|
|
|
|
|
{
|
|
|
|
|
var invisObj = UIFactory.CreateHorizontalGroup(topRowObj, new Color(1, 1, 1, 0));
|
|
|
|
|
var invisGroup = invisObj.GetComponent<HorizontalLayoutGroup>();
|
|
|
|
|
invisGroup.childForceExpandWidth = false;
|
|
|
|
|
invisGroup.childForceExpandHeight = false;
|
|
|
|
|
invisGroup.childControlWidth = true;
|
|
|
|
|
invisGroup.childControlHeight = true;
|
|
|
|
|
invisGroup.padding.top = 2;
|
|
|
|
|
invisGroup.padding.bottom = 2;
|
|
|
|
|
invisGroup.padding.left = 2;
|
|
|
|
|
invisGroup.padding.right = 2;
|
|
|
|
|
invisGroup.spacing = 10;
|
|
|
|
|
|
|
|
|
|
// inspect under mouse button
|
2021-03-18 17:17:29 +11:00
|
|
|
|
AddMouseInspectButton(topRowObj, InspectUnderMouse.MouseInspectMode.UI);
|
|
|
|
|
AddMouseInspectButton(topRowObj, InspectUnderMouse.MouseInspectMode.World);
|
2020-11-23 18:23:25 +11:00
|
|
|
|
}
|
2020-11-06 20:42:16 +11:00
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
private static void AddMouseInspectButton(GameObject topRowObj, InspectUnderMouse.MouseInspectMode mode)
|
2020-11-23 18:23:25 +11:00
|
|
|
|
{
|
2020-11-06 20:42:16 +11:00
|
|
|
|
var inspectObj = UIFactory.CreateButton(topRowObj);
|
|
|
|
|
var inspectLayout = inspectObj.AddComponent<LayoutElement>();
|
|
|
|
|
inspectLayout.minWidth = 120;
|
|
|
|
|
inspectLayout.flexibleWidth = 0;
|
2020-11-23 18:23:25 +11:00
|
|
|
|
|
|
|
|
|
var inspectText = inspectObj.GetComponentInChildren<Text>();
|
|
|
|
|
inspectText.text = "Mouse Inspect";
|
|
|
|
|
inspectText.fontSize = 13;
|
|
|
|
|
|
2021-03-18 17:17:29 +11:00
|
|
|
|
if (mode == InspectUnderMouse.MouseInspectMode.UI)
|
2020-11-23 18:23:25 +11:00
|
|
|
|
inspectText.text += " (UI)";
|
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
var inspectBtn = inspectObj.GetComponent<Button>();
|
|
|
|
|
var inspectColors = inspectBtn.colors;
|
|
|
|
|
inspectColors.normalColor = new Color(0.2f, 0.2f, 0.2f);
|
|
|
|
|
inspectBtn.colors = inspectColors;
|
2020-11-13 23:14:57 +11:00
|
|
|
|
|
2020-11-06 20:42:16 +11:00
|
|
|
|
inspectBtn.onClick.AddListener(OnInspectMouseClicked);
|
|
|
|
|
|
|
|
|
|
void OnInspectMouseClicked()
|
|
|
|
|
{
|
2021-03-18 17:17:29 +11:00
|
|
|
|
InspectUnderMouse.Mode = mode;
|
|
|
|
|
InspectUnderMouse.StartInspect();
|
2020-11-06 20:42:16 +11:00
|
|
|
|
}
|
2020-10-28 06:39:26 +11:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|