mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 14:17:51 +08:00
InfiniteScroll classes no longer need injection, using internal behaviour classes
This commit is contained in:
parent
a58e2a0fad
commit
896da0157d
@ -12,6 +12,7 @@ using UnityExplorer.UI.Models;
|
|||||||
using UnityExplorer.UI.Panels;
|
using UnityExplorer.UI.Panels;
|
||||||
using UnityExplorer.UI.Utility;
|
using UnityExplorer.UI.Utility;
|
||||||
using UnityExplorer.UI.Widgets;
|
using UnityExplorer.UI.Widgets;
|
||||||
|
using UnityExplorer.UI.Widgets.InfiniteScroll;
|
||||||
|
|
||||||
namespace UnityExplorer.UI
|
namespace UnityExplorer.UI
|
||||||
{
|
{
|
||||||
@ -44,14 +45,6 @@ namespace UnityExplorer.UI
|
|||||||
|
|
||||||
internal static void InitUI()
|
internal static void InitUI()
|
||||||
{
|
{
|
||||||
// inject custom types for il2cpp (not actually necessary for these to be MBs, but w/e)
|
|
||||||
// TODO MAKE THESE UIBEHAVIOURMODELS
|
|
||||||
#if CPP
|
|
||||||
UnhollowerRuntimeLib.ClassInjector.RegisterTypeInIl2Cpp<InfiniteScrollRect>();
|
|
||||||
UnhollowerRuntimeLib.ClassInjector.RegisterTypeInIl2Cpp<TransformTree>();
|
|
||||||
UnhollowerRuntimeLib.ClassInjector.RegisterTypeInIl2Cpp<TransformCell>();
|
|
||||||
#endif
|
|
||||||
|
|
||||||
LoadBundle();
|
LoadBundle();
|
||||||
|
|
||||||
UIFactory.Init();
|
UIFactory.Init();
|
||||||
@ -95,7 +88,7 @@ namespace UnityExplorer.UI
|
|||||||
if (EventSystem.current != EventSys)
|
if (EventSystem.current != EventSys)
|
||||||
CursorUnlocker.SetEventSystem();
|
CursorUnlocker.SetEventSystem();
|
||||||
|
|
||||||
// TODO MAKE THESE UIBEHAVIOURMODELS
|
// TODO could make these UIBehaviourModels
|
||||||
PanelDragger.UpdateInstances();
|
PanelDragger.UpdateInstances();
|
||||||
SliderScrollbar.UpdateInstances();
|
SliderScrollbar.UpdateInstances();
|
||||||
InputFieldScroller.UpdateInstances();
|
InputFieldScroller.UpdateInstances();
|
||||||
|
@ -8,14 +8,17 @@ using UnityExplorer.UI.Widgets.InfiniteScroll;
|
|||||||
|
|
||||||
namespace UnityExplorer.UI.Widgets
|
namespace UnityExplorer.UI.Widgets
|
||||||
{
|
{
|
||||||
public class TransformCell : MonoBehaviour, ICell
|
public class TransformCell : ICell
|
||||||
{
|
{
|
||||||
public bool Enabled => m_enabled;
|
public bool Enabled => m_enabled;
|
||||||
private bool m_enabled;
|
private bool m_enabled;
|
||||||
|
|
||||||
public TransformTree tree;
|
public TransformTree tree;
|
||||||
internal CachedTransform cachedTransform;
|
|
||||||
internal int _cellIndex;
|
public CachedTransform cachedTransform;
|
||||||
|
public int _cellIndex;
|
||||||
|
|
||||||
|
public GameObject uiRoot;
|
||||||
|
|
||||||
public Text nameLabel;
|
public Text nameLabel;
|
||||||
public Button nameButton;
|
public Button nameButton;
|
||||||
@ -25,8 +28,16 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
public LayoutElement spacer;
|
public LayoutElement spacer;
|
||||||
|
|
||||||
internal void Start()
|
public TransformCell(TransformTree tree, GameObject cellUI, Button nameButton, Button expandButton, LayoutElement spacer)
|
||||||
{
|
{
|
||||||
|
this.tree = tree;
|
||||||
|
this.uiRoot = cellUI;
|
||||||
|
this.nameButton = nameButton;
|
||||||
|
this.nameLabel = nameButton.GetComponentInChildren<Text>();
|
||||||
|
this.expandButton = expandButton;
|
||||||
|
this.expandLabel = expandButton.GetComponentInChildren<Text>();
|
||||||
|
this.spacer = spacer;
|
||||||
|
|
||||||
nameButton.onClick.AddListener(OnMainButtonClicked);
|
nameButton.onClick.AddListener(OnMainButtonClicked);
|
||||||
expandButton.onClick.AddListener(OnExpandClicked);
|
expandButton.onClick.AddListener(OnExpandClicked);
|
||||||
}
|
}
|
||||||
@ -42,12 +53,13 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
spacer.minWidth = cached.Depth * 15;
|
spacer.minWidth = cached.Depth * 15;
|
||||||
|
|
||||||
nameLabel.text = cached.Name;
|
nameLabel.text = cached.Value.name;
|
||||||
nameLabel.color = cached.RefTransform.gameObject.activeSelf ? Color.white : Color.grey;
|
nameLabel.color = cached.Value.gameObject.activeSelf ? Color.white : Color.grey;
|
||||||
|
|
||||||
if (cached.ChildCount > 0)
|
int childCount = cached.Value.childCount;
|
||||||
|
if (childCount > 0)
|
||||||
{
|
{
|
||||||
nameLabel.text = $"<color=grey>[{cached.ChildCount}]</color> {nameLabel.text}";
|
nameLabel.text = $"<color=grey>[{childCount}]</color> {nameLabel.text}";
|
||||||
|
|
||||||
expandButton.interactable = true;
|
expandButton.interactable = true;
|
||||||
expandLabel.enabled = true;
|
expandLabel.enabled = true;
|
||||||
@ -64,13 +76,13 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
public void Disable()
|
public void Disable()
|
||||||
{
|
{
|
||||||
m_enabled = false;
|
m_enabled = false;
|
||||||
this.gameObject.SetActive(false);
|
uiRoot.SetActive(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void Enable()
|
public void Enable()
|
||||||
{
|
{
|
||||||
m_enabled = true;
|
m_enabled = true;
|
||||||
this.gameObject.SetActive(true);
|
uiRoot.SetActive(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void OnExpandClicked()
|
public void OnExpandClicked()
|
||||||
@ -80,7 +92,46 @@ namespace UnityExplorer.UI.Widgets
|
|||||||
|
|
||||||
public void OnMainButtonClicked()
|
public void OnMainButtonClicked()
|
||||||
{
|
{
|
||||||
Debug.Log($"TODO Inspect {cachedTransform.RefTransform.name}");
|
if (cachedTransform.Value)
|
||||||
|
ExplorerCore.Log($"TODO Inspect {cachedTransform.Value.name}");
|
||||||
|
else
|
||||||
|
ExplorerCore.LogWarning("The object was destroyed!");
|
||||||
|
}
|
||||||
|
|
||||||
|
public static GameObject CreatePrototypeCell(GameObject parent)
|
||||||
|
{
|
||||||
|
var prototype = UIFactory.CreateHorizontalGroup(parent, "PrototypeCell", true, true, true, true, 2, default,
|
||||||
|
new Color(0.15f, 0.15f, 0.15f), TextAnchor.MiddleCenter);
|
||||||
|
//var cell = prototype.AddComponent<TransformCell>();
|
||||||
|
var rect = prototype.GetComponent<RectTransform>();
|
||||||
|
rect.anchorMin = new Vector2(0, 1);
|
||||||
|
rect.anchorMax = new Vector2(0, 1);
|
||||||
|
rect.pivot = new Vector2(0.5f, 1);
|
||||||
|
rect.sizeDelta = new Vector2(25, 25);
|
||||||
|
UIFactory.SetLayoutElement(prototype, minWidth: 100, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
|
var spacer = UIFactory.CreateUIObject("Spacer", prototype, new Vector2(0, 0));
|
||||||
|
UIFactory.SetLayoutElement(spacer, minWidth: 0, flexibleWidth: 0, minHeight: 0, flexibleHeight: 0);
|
||||||
|
|
||||||
|
var expandButton = UIFactory.CreateButton(prototype, "ExpandButton", "►", null);
|
||||||
|
UIFactory.SetLayoutElement(expandButton.gameObject, minWidth: 15, flexibleWidth: 0, minHeight: 25, flexibleHeight: 0);
|
||||||
|
|
||||||
|
var nameButton = UIFactory.CreateButton(prototype, "NameButton", "Name", null);
|
||||||
|
UIFactory.SetLayoutElement(nameButton.gameObject, flexibleWidth: 9999, minHeight: 25, flexibleHeight: 0);
|
||||||
|
var nameLabel = nameButton.GetComponentInChildren<Text>();
|
||||||
|
nameLabel.horizontalOverflow = HorizontalWrapMode.Overflow;
|
||||||
|
nameLabel.alignment = TextAnchor.MiddleLeft;
|
||||||
|
|
||||||
|
Color normal = new Color(0.15f, 0.15f, 0.15f);
|
||||||
|
Color highlight = new Color(0.25f, 0.25f, 0.25f);
|
||||||
|
Color pressed = new Color(0.05f, 0.05f, 0.05f);
|
||||||
|
Color disabled = new Color(1, 1, 1, 0);
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(expandButton, normal, highlight, pressed, disabled);
|
||||||
|
RuntimeProvider.Instance.SetColorBlock(nameButton, normal, highlight, pressed, disabled);
|
||||||
|
|
||||||
|
prototype.SetActive(false);
|
||||||
|
|
||||||
|
return prototype;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user