2021-04-25 00:21:12 +10:00
|
|
|
|
using System;
|
2021-04-26 19:56:21 +10:00
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
using UnityEngine;
|
2021-04-26 19:56:21 +10:00
|
|
|
|
using UnityExplorer.UI.ObjectPool;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
using UnityExplorer.UI.Panels;
|
|
|
|
|
|
|
|
|
|
namespace UnityExplorer.UI.Inspectors
|
|
|
|
|
{
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public abstract class InspectorBase : IPooledObject
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public bool IsActive { get; internal set; }
|
2021-04-28 23:58:13 +10:00
|
|
|
|
public object InspectorTarget { get; internal set; }
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-27 21:22:48 +10:00
|
|
|
|
public InspectorTab Tab { get; internal set; }
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public abstract GameObject UIRoot { get; }
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public float DefaultHeight => -1f;
|
2021-04-27 21:22:48 +10:00
|
|
|
|
public abstract GameObject CreateContent(GameObject parent);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public abstract void Update();
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public virtual void OnBorrowedFromPool(object target)
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2021-04-26 19:56:21 +10:00
|
|
|
|
Tab = Pool<InspectorTab>.Borrow();
|
|
|
|
|
Tab.UIRoot.transform.SetParent(InspectorPanel.Instance.NavbarHolder.transform, false);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
Tab.TabButton.OnClick += OnTabButtonClicked;
|
|
|
|
|
Tab.CloseButton.OnClick += OnCloseClicked;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public virtual void OnReturnToPool()
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2021-04-26 19:56:21 +10:00
|
|
|
|
Pool<InspectorTab>.Return(Tab);
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
Tab.TabButton.OnClick -= OnTabButtonClicked;
|
|
|
|
|
Tab.CloseButton.OnClick -= OnCloseClicked;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public virtual void OnSetActive()
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2021-04-28 23:58:13 +10:00
|
|
|
|
Tab.SetTabColor(true);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
UIRoot.SetActive(true);
|
|
|
|
|
IsActive = true;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
public virtual void OnSetInactive()
|
2021-04-25 00:21:12 +10:00
|
|
|
|
{
|
2021-04-28 23:58:13 +10:00
|
|
|
|
Tab.SetTabColor(false);
|
2021-04-26 19:56:21 +10:00
|
|
|
|
UIRoot.SetActive(false);
|
|
|
|
|
IsActive = false;
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
private void OnTabButtonClicked()
|
|
|
|
|
{
|
|
|
|
|
InspectorManager.SetInspectorActive(this);
|
|
|
|
|
}
|
2021-04-25 00:21:12 +10:00
|
|
|
|
|
2021-04-26 19:56:21 +10:00
|
|
|
|
protected abstract void OnCloseClicked();
|
2021-04-25 00:21:12 +10:00
|
|
|
|
}
|
|
|
|
|
}
|