mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-12 14:57:33 +08:00
Implemented Interactive List/Dictionary support (todo IL2CPP)
This commit is contained in:
@ -27,7 +27,7 @@ namespace UnityExplorer.UI.Shared
|
||||
|
||||
public event Action OnPageChanged;
|
||||
|
||||
private SliderScrollbar m_scrollbar;
|
||||
private readonly SliderScrollbar m_scrollbar;
|
||||
|
||||
// For now this is just set when the PageHandler is created, based on config.
|
||||
// At some point I might make it possible to change this after creation again.
|
||||
@ -147,7 +147,9 @@ namespace UnityExplorer.UI.Shared
|
||||
}
|
||||
if (didTurn)
|
||||
{
|
||||
m_scrollbar.m_scrollbar.value = 1;
|
||||
if (m_scrollbar != null)
|
||||
m_scrollbar.m_scrollbar.value = 1;
|
||||
|
||||
OnPageChanged?.Invoke();
|
||||
RefreshUI();
|
||||
}
|
||||
|
71
src/UI/Shared/ScrollRectEx.cs
Normal file
71
src/UI/Shared/ScrollRectEx.cs
Normal file
@ -0,0 +1,71 @@
|
||||
//using UnityEngine;
|
||||
//using System.Collections;
|
||||
//using UnityEngine.UI;
|
||||
//using System;
|
||||
//using UnityEngine.EventSystems;
|
||||
|
||||
|
||||
/////////////// kinda works, not really
|
||||
|
||||
|
||||
//public class ScrollRectEx : ScrollRect, IEventSystemHandler
|
||||
//{
|
||||
// internal SliderScrollbar sliderScrollbar;
|
||||
|
||||
// private bool ShouldRouteToParent(PointerEventData data)
|
||||
// => !sliderScrollbar.IsActive
|
||||
// || sliderScrollbar.m_slider.value < 0.001f && data.delta.y > 0
|
||||
// || sliderScrollbar.m_slider.value == 1f && data.delta.y < 0;
|
||||
|
||||
// private void DoForParents<T>(Action<T> action) where T : IEventSystemHandler
|
||||
// {
|
||||
// Transform parent = transform.parent;
|
||||
// while (parent != null)
|
||||
// {
|
||||
// foreach (var component in parent.GetComponents<Component>())
|
||||
// {
|
||||
// if (component is T)
|
||||
// action((T)(IEventSystemHandler)component);
|
||||
// }
|
||||
// parent = parent.parent;
|
||||
// }
|
||||
// }
|
||||
|
||||
// public override void OnScroll(PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IScrollHandler>((parent) => { parent.OnScroll(data); });
|
||||
// else
|
||||
// base.OnScroll(data);
|
||||
// }
|
||||
|
||||
// public override void OnInitializePotentialDrag(PointerEventData eventData)
|
||||
// {
|
||||
// DoForParents<IInitializePotentialDragHandler>((parent) => { parent.OnInitializePotentialDrag(eventData); });
|
||||
// base.OnInitializePotentialDrag(eventData);
|
||||
// }
|
||||
|
||||
// public override void OnDrag(PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IDragHandler>((parent) => { parent.OnDrag(data); });
|
||||
// else
|
||||
// base.OnDrag(data);
|
||||
// }
|
||||
|
||||
// public override void OnBeginDrag(UnityEngine.EventSystems.PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IBeginDragHandler>((parent) => { parent.OnBeginDrag(data); });
|
||||
// else
|
||||
// base.OnBeginDrag(data);
|
||||
// }
|
||||
|
||||
// public override void OnEndDrag(UnityEngine.EventSystems.PointerEventData data)
|
||||
// {
|
||||
// if (ShouldRouteToParent(data))
|
||||
// DoForParents<IEndDragHandler>((parent) => { parent.OnEndDrag(data); });
|
||||
// else
|
||||
// base.OnEndDrag(data);
|
||||
// }
|
||||
//}
|
@ -13,6 +13,8 @@ public class SliderScrollbar
|
||||
{
|
||||
internal static readonly List<SliderScrollbar> Instances = new List<SliderScrollbar>();
|
||||
|
||||
public bool IsActive { get; private set; }
|
||||
|
||||
internal readonly Scrollbar m_scrollbar;
|
||||
internal readonly Slider m_slider;
|
||||
internal readonly RectTransform m_scrollRect;
|
||||
@ -46,21 +48,25 @@ public class SliderScrollbar
|
||||
internal void Update()
|
||||
{
|
||||
this.RefreshVisibility();
|
||||
}
|
||||
}
|
||||
|
||||
internal void RefreshVisibility()
|
||||
{
|
||||
if (!m_slider.gameObject.activeInHierarchy)
|
||||
{
|
||||
IsActive = false;
|
||||
return;
|
||||
}
|
||||
|
||||
bool shouldShow = !Mathf.Approximately(this.m_scrollbar.size, 1);
|
||||
var obj = this.m_slider.handleRect.gameObject;
|
||||
|
||||
if (obj.activeSelf != shouldShow)
|
||||
if (IsActive != shouldShow)
|
||||
{
|
||||
obj.SetActive(shouldShow);
|
||||
IsActive = shouldShow;
|
||||
obj.SetActive(IsActive);
|
||||
|
||||
if (shouldShow)
|
||||
if (IsActive)
|
||||
this.m_slider.Set(this.m_scrollbar.value, false);
|
||||
else
|
||||
m_slider.Set(1f, false);
|
||||
|
@ -542,7 +542,7 @@ namespace UnityExplorer.UI
|
||||
templateImage.type = Image.Type.Sliced;
|
||||
templateImage.color = new Color(0.15f, 0.15f, 0.15f, 1.0f);
|
||||
|
||||
ScrollRect scrollRect = templateObj.AddComponent<ScrollRect>();
|
||||
var scrollRect = templateObj.AddComponent<ScrollRect>();
|
||||
scrollRect.scrollSensitivity = 35;
|
||||
scrollRect.content = contentObj.GetComponent<RectTransform>();
|
||||
scrollRect.viewport = viewportObj.GetComponent<RectTransform>();
|
||||
@ -626,7 +626,7 @@ namespace UnityExplorer.UI
|
||||
|
||||
var mainLayout = mainObj.AddComponent<LayoutElement>();
|
||||
mainLayout.minWidth = 100;
|
||||
mainLayout.minHeight = 100;
|
||||
mainLayout.minHeight = 30;
|
||||
mainLayout.flexibleWidth = 5000;
|
||||
mainLayout.flexibleHeight = 5000;
|
||||
|
||||
@ -709,6 +709,8 @@ namespace UnityExplorer.UI
|
||||
// Create a custom DynamicScrollbar module
|
||||
scroller = new SliderScrollbar(hiddenScroll, scrollSlider);
|
||||
|
||||
//scrollRect.sliderScrollbar = scroller;
|
||||
|
||||
return mainObj;
|
||||
}
|
||||
}
|
||||
|
@ -30,17 +30,14 @@ namespace UnityExplorer.UI
|
||||
|
||||
internal static string GetClassColor(Type type)
|
||||
{
|
||||
string classColor;
|
||||
if (type.IsAbstract && type.IsSealed)
|
||||
classColor = Class_Static;
|
||||
return Class_Static;
|
||||
else if (type.IsEnum || type.IsGenericParameter)
|
||||
classColor = Enum;
|
||||
return Enum;
|
||||
else if (type.IsValueType)
|
||||
classColor = StructGreen;
|
||||
return StructGreen;
|
||||
else
|
||||
classColor = Class_Instance;
|
||||
|
||||
return classColor;
|
||||
return Class_Instance;
|
||||
}
|
||||
|
||||
public static string ParseFullSyntax(Type type, bool includeNamespace, MemberInfo memberInfo = null)
|
||||
|
Reference in New Issue
Block a user