2021-04-26 19:56:21 +10:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
|
using UnityEngine;
|
|
|
|
|
using UnityEngine.UI;
|
|
|
|
|
using UnityExplorer.UI.ObjectPool;
|
|
|
|
|
using UnityExplorer.UI.Widgets;
|
|
|
|
|
|
|
|
|
|
namespace UnityExplorer.UI.Inspectors
|
|
|
|
|
{
|
|
|
|
|
public class InspectorTab : IPooledObject
|
|
|
|
|
{
|
2021-05-01 20:55:27 +10:00
|
|
|
|
public GameObject UIRoot { get; set; }
|
2021-04-26 19:56:21 +10:00
|
|
|
|
|
|
|
|
|
public float DefaultHeight => 25f;
|
|
|
|
|
|
|
|
|
|
public ButtonRef TabButton;
|
|
|
|
|
public Text TabText;
|
|
|
|
|
|
|
|
|
|
public ButtonRef CloseButton;
|
|
|
|
|
|
2021-04-28 23:58:13 +10:00
|
|
|
|
private static readonly Color _enabledTabColor = new Color(0.15f, 0.22f, 0.15f);
|
|
|
|
|
private static readonly Color _disabledTabColor = new Color(0.13f, 0.13f, 0.13f);
|
|
|
|
|
|
|
|
|
|
public void SetTabColor(bool active)
|
|
|
|
|
{
|
|
|
|
|
if (active)
|
2021-05-11 19:18:27 +10:00
|
|
|
|
RuntimeProvider.Instance.SetColorBlock(TabButton.Component, _enabledTabColor, _enabledTabColor * 1.2f);
|
2021-04-28 23:58:13 +10:00
|
|
|
|
else
|
2021-05-11 19:18:27 +10:00
|
|
|
|
RuntimeProvider.Instance.SetColorBlock(TabButton.Component, _disabledTabColor, _disabledTabColor * 1.2f);
|
2021-04-28 23:58:13 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public GameObject CreateContent(GameObject parent)
|
|
|
|
|
{
|
2021-05-01 20:55:27 +10:00
|
|
|
|
UIRoot = UIFactory.CreateHorizontalGroup(parent, "TabObject", true, true, true, true, 0,
|
2021-04-28 23:58:13 +10:00
|
|
|
|
new Vector4(0, 0, 3, 0), new Color(0.13f, 0.13f, 0.13f));
|
2021-05-01 20:55:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(UIRoot, minWidth: 185, flexibleWidth: 0);
|
|
|
|
|
UIRoot.AddComponent<Mask>();
|
2021-04-26 19:56:21 +10:00
|
|
|
|
|
2021-05-01 20:55:27 +10:00
|
|
|
|
TabButton = UIFactory.CreateButton(UIRoot, "TabButton", "");
|
2021-04-26 19:56:21 +10:00
|
|
|
|
|
2021-05-11 19:18:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(TabButton.Component.gameObject, minWidth: 165, flexibleWidth: 0);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
|
2021-05-11 19:18:27 +10:00
|
|
|
|
TabText = TabButton.Component.GetComponentInChildren<Text>();
|
2021-04-26 19:56:21 +10:00
|
|
|
|
TabText.horizontalOverflow = HorizontalWrapMode.Overflow;
|
|
|
|
|
TabText.alignment = TextAnchor.MiddleLeft;
|
|
|
|
|
|
2021-05-01 20:55:27 +10:00
|
|
|
|
CloseButton = UIFactory.CreateButton(UIRoot, "CloseButton", "X", new Color(0.2f, 0.2f, 0.2f, 1));
|
2021-05-11 19:18:27 +10:00
|
|
|
|
UIFactory.SetLayoutElement(CloseButton.Component.gameObject, minWidth: 20, flexibleWidth: 0);
|
|
|
|
|
var closeBtnText = CloseButton.Component.GetComponentInChildren<Text>();
|
2021-04-26 19:56:21 +10:00
|
|
|
|
closeBtnText.color = Color.red;
|
|
|
|
|
|
2021-05-01 20:55:27 +10:00
|
|
|
|
return UIRoot;
|
2021-04-26 19:56:21 +10:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|