mirror of
https://github.com/GrahamKracker/UnityExplorer.git
synced 2025-07-03 03:52:28 +08:00
Some progress on inspector rewrites, most of the framework figured out now.
This commit is contained in:
@ -7,8 +7,8 @@ using UnityEngine.UI;
|
||||
using UnityExplorer.Core.Input;
|
||||
using UnityExplorer.Core.Runtime;
|
||||
using UnityExplorer.UI;
|
||||
using UnityExplorer.UI.Models;
|
||||
using UnityExplorer.UI.ObjectPool;
|
||||
using UnityExplorer.UI.Panels;
|
||||
|
||||
namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
{
|
||||
|
@ -15,13 +15,13 @@ namespace UnityExplorer.UI.Widgets
|
||||
public Action<int> OnClick;
|
||||
public int CurrentDataIndex;
|
||||
|
||||
public GameObject UIRoot => uiRoot;
|
||||
public GameObject uiRoot;
|
||||
|
||||
public ButtonRef Button;
|
||||
|
||||
#region ICell
|
||||
|
||||
public GameObject UIRoot => uiRoot;
|
||||
public GameObject uiRoot;
|
||||
|
||||
public bool Enabled => m_enabled;
|
||||
private bool m_enabled;
|
||||
|
||||
@ -69,7 +69,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
Button.OnClick += () => { OnClick?.Invoke(CurrentDataIndex); };
|
||||
|
||||
return m_rect.gameObject;
|
||||
return uiRoot;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -97,9 +97,9 @@ namespace UnityExplorer.UI.Widgets
|
||||
{
|
||||
string text;
|
||||
if (m_context == SearchContext.StaticClass)
|
||||
text = SignatureHighlighter.HighlightTypeName(currentResults[index].GetActualType());
|
||||
text = SignatureHighlighter.HighlightTypeName(currentResults[index] as Type, true, true);
|
||||
else
|
||||
text = ToStringUtility.ToString(currentResults[index], currentResults[index].GetActualType());
|
||||
text = ToStringUtility.ToStringWithType(currentResults[index], currentResults[index]?.GetActualType());
|
||||
|
||||
cachedCellTexts.Add(index, text);
|
||||
}
|
||||
@ -110,7 +110,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
private void OnCellClicked(int dataIndex)
|
||||
{
|
||||
if (m_context == SearchContext.StaticClass)
|
||||
InspectorManager.Inspect(currentResults[dataIndex] as Type);
|
||||
InspectorManager.InspectStatic(currentResults[dataIndex] as Type);
|
||||
else
|
||||
InspectorManager.Inspect(currentResults[dataIndex]);
|
||||
}
|
||||
|
@ -16,15 +16,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
public int cellIndex, dataIndex;
|
||||
}
|
||||
|
||||
//public abstract class ScrollPool : UIBehaviourModel
|
||||
//{
|
||||
// public abstract IPoolDataSource DataSource { get; set; }
|
||||
// public abstract RectTransform PrototypeCell { get; }
|
||||
//
|
||||
// public abstract void Initialize(IPoolDataSource dataSource);
|
||||
//
|
||||
//}
|
||||
|
||||
/// <summary>
|
||||
/// An object-pooled ScrollRect, attempts to support content of any size and provide a scrollbar for it.
|
||||
/// </summary>
|
||||
@ -37,12 +28,16 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
public IPoolDataSource<T> DataSource { get; set; }
|
||||
|
||||
public readonly List<T> CellPool = new List<T>();
|
||||
|
||||
internal DataHeightCache<T> HeightCache;
|
||||
|
||||
public float PrototypeHeight => _protoHeight ?? (float)(_protoHeight = Pool<T>.Instance.DefaultHeight);
|
||||
private float? _protoHeight;
|
||||
|
||||
//private float PrototypeHeight => DefaultHeight.rect.height;
|
||||
|
||||
public int ExtraPoolCells => 6;
|
||||
public int ExtraPoolCells => 10;
|
||||
public float RecycleThreshold => PrototypeHeight * ExtraPoolCells;
|
||||
public float HalfThreshold => RecycleThreshold * 0.5f;
|
||||
|
||||
@ -76,10 +71,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
private int bottomDataIndex;
|
||||
private int TopDataIndex => Math.Max(0, bottomDataIndex - CellPool.Count + 1);
|
||||
|
||||
private readonly List<T> CellPool = new List<T>();
|
||||
|
||||
internal DataHeightCache<T> HeightCache;
|
||||
|
||||
private float TotalDataHeight => HeightCache.TotalHeight + contentLayout.padding.top + contentLayout.padding.bottom;
|
||||
|
||||
/// <summary>
|
||||
@ -269,12 +260,12 @@ namespace UnityExplorer.UI.Widgets
|
||||
if (andResetDataIndex)
|
||||
bottomDataIndex = CellPool.Count - 1;
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
|
||||
// after creating pool, set displayed cells.
|
||||
var enumerator = GetPoolEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
SetCell(CellPool[enumerator.Current.cellIndex], enumerator.Current.dataIndex);
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
}
|
||||
|
||||
/// <summary>ret = cell pool was extended</summary>
|
||||
@ -303,13 +294,13 @@ namespace UnityExplorer.UI.Widgets
|
||||
{
|
||||
WritingLocked = true;
|
||||
|
||||
// Disable cells so DataSource can handle its content if need be
|
||||
var enumerator = GetPoolEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
{
|
||||
var curr = enumerator.Current;
|
||||
DataSource.DisableCell(CellPool[curr.cellIndex], curr.dataIndex);
|
||||
}
|
||||
//// Disable cells so DataSource can handle its content if need be
|
||||
//var enumerator = GetPoolEnumerator();
|
||||
//while (enumerator.MoveNext())
|
||||
//{
|
||||
// var curr = enumerator.Current;
|
||||
// DataSource.DisableCell(CellPool[curr.cellIndex], curr.dataIndex);
|
||||
//}
|
||||
|
||||
bottomDataIndex += cellsRequired;
|
||||
int maxDataIndex = Math.Max(CellPool.Count + cellsRequired - 1, DataSource.ItemCount - 1);
|
||||
@ -438,14 +429,16 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
private void OnValueChangedListener(Vector2 val)
|
||||
{
|
||||
if (WritingLocked)
|
||||
if (WritingLocked || !m_initialized)
|
||||
return;
|
||||
|
||||
if (InputManager.MouseScrollDelta != Vector2.zero)
|
||||
ScrollRect.StopMovement();
|
||||
|
||||
if (!SetRecycleViewBounds(true))
|
||||
RefreshCells(false);
|
||||
SetRecycleViewBounds(true);
|
||||
|
||||
//if (!SetRecycleViewBounds(true))
|
||||
// RefreshCells(false);
|
||||
|
||||
float yChange = (ScrollRect.content.anchoredPosition - prevAnchoredPos).y;
|
||||
float adjust = 0f;
|
||||
@ -605,7 +598,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
private void OnSliderValueChanged(float val)
|
||||
{
|
||||
if (this.WritingLocked)
|
||||
if (this.WritingLocked || !m_initialized)
|
||||
return;
|
||||
this.WritingLocked = true;
|
||||
|
||||
|
Reference in New Issue
Block a user