mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-15 15:57:52 +08:00
Namespace cleanup, move some categories out of UI namespace
This commit is contained in:
69
src/Inspectors/InspectorBase.cs
Normal file
69
src/Inspectors/InspectorBase.cs
Normal file
@ -0,0 +1,69 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using UnityEngine;
|
||||
using UnityEngine.UI;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Models;
|
||||
using UnityExplorer.UI.Panels;
|
||||
|
||||
namespace UnityExplorer.Inspectors
|
||||
{
|
||||
public abstract class InspectorBase : IPooledObject
|
||||
{
|
||||
public bool IsActive { get; internal set; }
|
||||
public object Target { get; set; }
|
||||
|
||||
public InspectorTab Tab { get; internal set; }
|
||||
|
||||
public GameObject UIRoot { get; set; }
|
||||
|
||||
public float DefaultHeight => -1f;
|
||||
public abstract GameObject CreateContent(GameObject parent);
|
||||
|
||||
public abstract void Update();
|
||||
|
||||
public abstract void CloseInspector();
|
||||
|
||||
public virtual void OnBorrowedFromPool(object target)
|
||||
{
|
||||
this.Target = target;
|
||||
Tab = Pool<InspectorTab>.Borrow();
|
||||
Tab.UIRoot.transform.SetParent(InspectorPanel.Instance.NavbarHolder.transform, false);
|
||||
|
||||
Tab.TabButton.OnClick += OnTabButtonClicked;
|
||||
Tab.CloseButton.OnClick += CloseInspector;
|
||||
}
|
||||
|
||||
public virtual void OnReturnToPool()
|
||||
{
|
||||
Pool<InspectorTab>.Return(Tab);
|
||||
|
||||
this.Target = null;
|
||||
|
||||
Tab.TabButton.OnClick -= OnTabButtonClicked;
|
||||
Tab.CloseButton.OnClick -= CloseInspector;
|
||||
}
|
||||
|
||||
public virtual void OnSetActive()
|
||||
{
|
||||
Tab.SetTabColor(true);
|
||||
UIRoot.SetActive(true);
|
||||
IsActive = true;
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(UIRoot.GetComponent<RectTransform>());
|
||||
}
|
||||
|
||||
public virtual void OnSetInactive()
|
||||
{
|
||||
Tab.SetTabColor(false);
|
||||
UIRoot.SetActive(false);
|
||||
IsActive = false;
|
||||
}
|
||||
|
||||
private void OnTabButtonClicked()
|
||||
{
|
||||
InspectorManager.SetInspectorActive(this);
|
||||
}
|
||||
}
|
||||
}
|
Reference in New Issue
Block a user