mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-06-16 14:17:51 +08:00
Cleanup
This commit is contained in:
parent
2378925a8b
commit
74ff1d8f01
@ -72,7 +72,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
||||
|
||||
// On parent destroying this
|
||||
|
||||
public virtual void OnDestroyed()
|
||||
public virtual void ReleasePooledObjects()
|
||||
{
|
||||
// TODO release IValue / Evaluate back to pool, etc
|
||||
ReleaseIValue();
|
||||
@ -237,6 +237,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject
|
||||
if (this.IValue == null)
|
||||
{
|
||||
IValue = (InteractiveValue)Pool.Borrow(typeof(InteractiveValue));
|
||||
CurrentIValueType = IValue.GetType();
|
||||
IValue.SetOwner(this);
|
||||
IValue.UIRoot.transform.SetParent(CellView.SubContentHolder.transform, false);
|
||||
CellView.SubContentHolder.SetActive(true);
|
||||
|
@ -10,7 +10,7 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
|
||||
{
|
||||
public class CacheMemberCell : CacheObjectCell
|
||||
{
|
||||
public ReflectionInspector CurrentOwner { get; set; }
|
||||
public ReflectionInspector Owner { get; set; }
|
||||
|
||||
public CacheMember MemberOccupant => Occupant as CacheMember;
|
||||
|
||||
@ -24,15 +24,6 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
|
||||
// TODO
|
||||
}
|
||||
|
||||
public override void OnReturnToPool()
|
||||
{
|
||||
base.OnReturnToPool();
|
||||
|
||||
// TODO ?
|
||||
|
||||
CurrentOwner = null;
|
||||
}
|
||||
|
||||
protected override void ConstructEvaluateHolder(GameObject parent)
|
||||
{
|
||||
// Evaluate vert group
|
||||
|
@ -59,18 +59,6 @@ namespace UnityExplorer.UI.Inspectors.CacheObject.Views
|
||||
|
||||
public GameObject SubContentHolder;
|
||||
|
||||
public virtual void OnReturnToPool()
|
||||
{
|
||||
if (Occupant != null)
|
||||
{
|
||||
// TODO ?
|
||||
|
||||
SubContentHolder.SetActive(false);
|
||||
|
||||
Occupant = null;
|
||||
}
|
||||
}
|
||||
|
||||
protected virtual void ApplyClicked()
|
||||
{
|
||||
Occupant.OnCellApplyClicked();
|
||||
|
@ -49,7 +49,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
|
||||
TransformTree.Rebuild();
|
||||
|
||||
ComponentList.ScrollPool.Rebuild();
|
||||
ComponentList.ScrollPool.Refresh(true, true);
|
||||
UpdateComponents();
|
||||
}
|
||||
|
||||
@ -57,12 +57,12 @@ namespace UnityExplorer.UI.Inspectors
|
||||
{
|
||||
base.OnReturnToPool();
|
||||
|
||||
// release component and transform lists
|
||||
this.TransformTree.ScrollPool.ReturnCells();
|
||||
this.TransformTree.ScrollPool.SetUninitialized();
|
||||
|
||||
this.ComponentList.ScrollPool.ReturnCells();
|
||||
this.ComponentList.ScrollPool.SetUninitialized();
|
||||
//// release component and transform lists
|
||||
//this.TransformTree.ScrollPool.ReleaseCells();
|
||||
//this.TransformTree.ScrollPool.SetUninitialized();
|
||||
//
|
||||
//this.ComponentList.ScrollPool.ReleaseCells();
|
||||
//this.ComponentList.ScrollPool.SetUninitialized();
|
||||
}
|
||||
|
||||
private float timeOfLastUpdate;
|
||||
@ -150,7 +150,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
_componentEntries.Add(comp);
|
||||
|
||||
ComponentList.RefreshData();
|
||||
ComponentList.ScrollPool.RefreshCells(true);
|
||||
ComponentList.ScrollPool.Refresh(true);
|
||||
}
|
||||
|
||||
protected override void OnCloseClicked()
|
||||
|
@ -46,7 +46,8 @@ namespace UnityExplorer.UI.Inspectors
|
||||
SetTitleLayouts();
|
||||
SetTarget(target);
|
||||
|
||||
MemberScrollPool.Initialize(this);
|
||||
// MemberScrollPool.SetDataSource(this);
|
||||
MemberScrollPool.Refresh(true, true);
|
||||
RuntimeProvider.Instance.StartCoroutine(InitCoroutine());
|
||||
}
|
||||
|
||||
@ -60,11 +61,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
public override void OnReturnToPool()
|
||||
{
|
||||
foreach (var member in members)
|
||||
member.OnDestroyed();
|
||||
|
||||
// release all cachememberviews
|
||||
MemberScrollPool.ReturnCells();
|
||||
MemberScrollPool.SetUninitialized();
|
||||
member.ReleasePooledObjects();
|
||||
|
||||
members.Clear();
|
||||
filteredMembers.Clear();
|
||||
@ -173,7 +170,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
}
|
||||
|
||||
if (shouldRefresh)
|
||||
MemberScrollPool.RefreshCells(false);
|
||||
MemberScrollPool.Refresh(false);
|
||||
}
|
||||
|
||||
// Member cells
|
||||
@ -182,12 +179,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
|
||||
public void OnCellBorrowed(CacheMemberCell cell)
|
||||
{
|
||||
cell.CurrentOwner = this;
|
||||
}
|
||||
|
||||
public void OnCellReturned(CacheMemberCell cell)
|
||||
{
|
||||
cell.OnReturnToPool();
|
||||
cell.Owner = this;
|
||||
}
|
||||
|
||||
public void SetCell(CacheMemberCell cell, int index)
|
||||
@ -315,6 +307,7 @@ namespace UnityExplorer.UI.Inspectors
|
||||
MemberScrollPool = UIFactory.CreateScrollPool<CacheMemberCell>(uiRoot, "MemberList", out GameObject scrollObj,
|
||||
out GameObject _, new Color(0.09f, 0.09f, 0.09f));
|
||||
UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999);
|
||||
MemberScrollPool.Initialize(this);
|
||||
|
||||
//InspectorPanel.Instance.UIRoot.GetComponent<Mask>().enabled = false;
|
||||
//MemberScrollPool.Viewport.GetComponent<Mask>().enabled = false;
|
||||
|
@ -83,7 +83,7 @@ namespace UnityExplorer.UI.Panels
|
||||
}
|
||||
|
||||
dataHandler.RefreshData();
|
||||
resultsScrollPool.RefreshCells(true);
|
||||
resultsScrollPool.Refresh(true);
|
||||
|
||||
resultsLabel.text = $"{currentResults.Count} results";
|
||||
}
|
||||
@ -212,7 +212,7 @@ namespace UnityExplorer.UI.Panels
|
||||
//if (!Pool<ButtonCell>.PrototypeObject)
|
||||
// Pool<ButtonCell>.PrototypeObject = ButtonCell.CreatePrototypeCell(Pool<ButtonCell>.InactiveHolder).gameObject;
|
||||
|
||||
resultsScrollPool.Initialize(dataHandler);//, ButtonCell.CreatePrototypeCell(uiRoot));
|
||||
resultsScrollPool.Initialize(dataHandler);
|
||||
UIFactory.SetLayoutElement(scrollObj, flexibleHeight: 9999);
|
||||
}
|
||||
}
|
@ -116,7 +116,7 @@ namespace UnityExplorer.UI.Widgets.AutoComplete
|
||||
UIRoot.SetActive(true);
|
||||
UIRoot.transform.SetAsLastSibling();
|
||||
dataHandler.RefreshData();
|
||||
scrollPool.RefreshAndJumpToTop();
|
||||
scrollPool.Refresh(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
cell.OnClick += OnCellClicked;
|
||||
}
|
||||
|
||||
public void OnCellReturned(ButtonCell cell)
|
||||
public void ReleaseCell(ButtonCell cell)
|
||||
{
|
||||
cell.OnClick -= OnCellClicked;
|
||||
}
|
||||
|
@ -1,83 +0,0 @@
|
||||
//using System;
|
||||
//using System.Collections.Generic;
|
||||
//using System.Linq;
|
||||
//using System.Text;
|
||||
//using UnityEngine;
|
||||
//using UnityEngine.UI;
|
||||
|
||||
//namespace UnityExplorer.UI.Widgets
|
||||
//{
|
||||
// public class CellViewHolder : ICell
|
||||
// {
|
||||
// public CellViewHolder(GameObject uiRoot)
|
||||
// {
|
||||
// this.UIRoot = uiRoot;
|
||||
// this.Rect = uiRoot.GetComponent<RectTransform>();
|
||||
// m_enabled = uiRoot.activeSelf;
|
||||
// }
|
||||
|
||||
// public bool Enabled => m_enabled;
|
||||
// private bool m_enabled;
|
||||
|
||||
// public GameObject UIRoot { get; }
|
||||
// public RectTransform Rect { get; }
|
||||
|
||||
// private GameObject m_content;
|
||||
|
||||
// public GameObject SetContent(GameObject newContent)
|
||||
// {
|
||||
// var ret = m_content;
|
||||
|
||||
// if (ret && newContent && ret.ReferenceEqual(newContent))
|
||||
// return null;
|
||||
|
||||
// newContent.transform.SetParent(this.UIRoot.transform, false);
|
||||
// (this as ICell).Enable();
|
||||
|
||||
// m_content = newContent;
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
// public GameObject DisableContent()
|
||||
// {
|
||||
// var ret = m_content;
|
||||
// (this as ICell).Disable();
|
||||
// return ret;
|
||||
// }
|
||||
|
||||
// void ICell.Enable()
|
||||
// {
|
||||
// m_enabled = true;
|
||||
// UIRoot.SetActive(true);
|
||||
// }
|
||||
|
||||
// void ICell.Disable()
|
||||
// {
|
||||
// m_enabled = false;
|
||||
// UIRoot.SetActive(false);
|
||||
// }
|
||||
|
||||
// public static RectTransform CreatePrototypeCell(GameObject parent)
|
||||
// {
|
||||
// // using an image on the cell view holder is fine, we only need to make about 20-50 of these per pool.
|
||||
// var prototype = UIFactory.CreateVerticalGroup(parent, "PrototypeCell", true, true, true, true, 0, new Vector4(0, 0, 0, 0),
|
||||
// new Color(0.11f, 0.11f, 0.11f), TextAnchor.MiddleCenter);
|
||||
|
||||
// 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(100, 30);
|
||||
|
||||
// prototype.AddComponent<ContentSizeFitter>().verticalFit = ContentSizeFitter.FitMode.PreferredSize;
|
||||
|
||||
// var sepObj = UIFactory.CreateUIObject("separator", prototype);
|
||||
// sepObj.AddComponent<Image>().color = Color.black;
|
||||
// UIFactory.SetLayoutElement(sepObj, minHeight: 1, preferredHeight: 1, flexibleHeight: 0);
|
||||
|
||||
// prototype.SetActive(false);
|
||||
|
||||
// return rect;
|
||||
// }
|
||||
// }
|
||||
//}
|
@ -11,7 +11,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
int ItemCount { get; }
|
||||
|
||||
void OnCellBorrowed(T cell);
|
||||
void OnCellReturned(T cell);
|
||||
//void ReleaseCell(T cell);
|
||||
|
||||
void SetCell(T cell, int index);
|
||||
//void DisableCell(T cell, int index);
|
||||
|
@ -35,9 +35,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
public float PrototypeHeight => _protoHeight ?? (float)(_protoHeight = Pool<T>.Instance.DefaultHeight);
|
||||
private float? _protoHeight;
|
||||
|
||||
//private float PrototypeHeight => DefaultHeight.rect.height;
|
||||
|
||||
public int ExtraPoolCells => 10;
|
||||
public int ExtraPoolCells => 6;
|
||||
public float RecycleThreshold => PrototypeHeight * ExtraPoolCells;
|
||||
public float HalfThreshold => RecycleThreshold * 0.5f;
|
||||
|
||||
@ -70,6 +68,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
/// </summary>
|
||||
private int bottomDataIndex;
|
||||
private int TopDataIndex => Math.Max(0, bottomDataIndex - CellPool.Count + 1);
|
||||
private int CurrentDataCount => bottomDataIndex + 1;
|
||||
|
||||
private float TotalDataHeight => HeightCache.TotalHeight + contentLayout.padding.top + contentLayout.padding.bottom;
|
||||
|
||||
@ -78,8 +77,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
/// </summary>
|
||||
private int topPoolIndex, bottomPoolIndex;
|
||||
|
||||
private int CurrentDataCount => bottomDataIndex + 1;
|
||||
|
||||
private Vector2 prevAnchoredPos;
|
||||
private float prevViewportHeight;
|
||||
|
||||
@ -102,14 +99,9 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
private float prevContentHeight = 1.0f;
|
||||
|
||||
public void SetUninitialized()
|
||||
{
|
||||
m_initialized = false;
|
||||
}
|
||||
|
||||
public override void Update()
|
||||
{
|
||||
if (!m_initialized || !ScrollRect || DataSource == null)
|
||||
if (!ScrollRect || DataSource == null)
|
||||
return;
|
||||
|
||||
if (writingLocked && timeofLastWriteLock < Time.time)
|
||||
@ -129,65 +121,38 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
// Public methods
|
||||
|
||||
public void Rebuild()
|
||||
public void Refresh(bool setCellData, bool jumpToTop = false)
|
||||
{
|
||||
HeightCache = new DataHeightCache<T>(this);
|
||||
if (jumpToTop)
|
||||
{
|
||||
bottomDataIndex = CellPool.Count - 1;
|
||||
Content.anchoredPosition = Vector2.zero;
|
||||
}
|
||||
|
||||
SetRecycleViewBounds(false);
|
||||
SetScrollBounds();
|
||||
|
||||
CheckExtendCellPool();
|
||||
writingLocked = false;
|
||||
Content.anchoredPosition = Vector2.zero;
|
||||
UpdateSliderHandle(true);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
public void RefreshAndJumpToTop()
|
||||
{
|
||||
bottomDataIndex = CellPool.Count - 1;
|
||||
RefreshCells(true);
|
||||
Content.anchoredPosition = Vector2.zero;
|
||||
UpdateSliderHandle(true);
|
||||
}
|
||||
|
||||
public void RecreateHeightCache()
|
||||
{
|
||||
HeightCache = new DataHeightCache<T>(this);
|
||||
CheckDataSourceCountChange(out _);
|
||||
}
|
||||
|
||||
public void RefreshCells(bool reloadData)
|
||||
{
|
||||
RefreshCells(reloadData, true);
|
||||
RefreshCells(setCellData, true);
|
||||
}
|
||||
|
||||
// Initialize
|
||||
|
||||
private bool m_doneFirstInit;
|
||||
private bool m_initialized;
|
||||
//private bool Initialized;
|
||||
|
||||
/// <summary>Should be called only once, when the scroll pool is created.</summary>
|
||||
public void Initialize(IPoolDataSource<T> dataSource)
|
||||
{
|
||||
this.DataSource = dataSource;
|
||||
HeightCache = new DataHeightCache<T>(this);
|
||||
|
||||
// Ensure the pool for the cell type is initialized.
|
||||
Pool<T>.GetPool();
|
||||
|
||||
HeightCache = new DataHeightCache<T>(this);
|
||||
DataSource = dataSource;
|
||||
this.contentLayout = ScrollRect.content.GetComponent<VerticalLayoutGroup>();
|
||||
this.slider = ScrollRect.GetComponentInChildren<Slider>();
|
||||
slider.onValueChanged.AddListener(OnSliderValueChanged);
|
||||
|
||||
if (!m_doneFirstInit)
|
||||
{
|
||||
m_doneFirstInit = true;
|
||||
this.contentLayout = ScrollRect.content.GetComponent<VerticalLayoutGroup>();
|
||||
this.slider = ScrollRect.GetComponentInChildren<Slider>();
|
||||
slider.onValueChanged.AddListener(OnSliderValueChanged);
|
||||
ScrollRect.vertical = true;
|
||||
ScrollRect.horizontal = false;
|
||||
|
||||
ScrollRect.vertical = true;
|
||||
ScrollRect.horizontal = false;
|
||||
}
|
||||
|
||||
ScrollRect.onValueChanged.RemoveListener(OnValueChangedListener);
|
||||
//ScrollRect.onValueChanged.RemoveListener(OnValueChangedListener);
|
||||
RuntimeProvider.Instance.StartCoroutine(InitCoroutine());
|
||||
}
|
||||
|
||||
@ -196,6 +161,8 @@ namespace UnityExplorer.UI.Widgets
|
||||
ScrollRect.content.anchoredPosition = Vector2.zero;
|
||||
yield return null;
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
|
||||
// set intial bounds
|
||||
prevAnchoredPos = Content.anchoredPosition;
|
||||
SetRecycleViewBounds(false);
|
||||
@ -203,14 +170,18 @@ namespace UnityExplorer.UI.Widgets
|
||||
// create initial cell pool and set cells
|
||||
CreateCellPool();
|
||||
|
||||
var enumerator = GetPoolEnumerator();
|
||||
while (enumerator.MoveNext())
|
||||
SetCell(CellPool[enumerator.Current.cellIndex], enumerator.Current.dataIndex);
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
|
||||
// update slider
|
||||
SetScrollBounds();
|
||||
UpdateSliderHandle();
|
||||
|
||||
// add onValueChanged listener after setup
|
||||
ScrollRect.onValueChanged.AddListener(OnValueChangedListener);
|
||||
|
||||
m_initialized = true;
|
||||
}
|
||||
|
||||
private void SetScrollBounds()
|
||||
@ -218,28 +189,43 @@ namespace UnityExplorer.UI.Widgets
|
||||
NormalizedScrollBounds = new Vector2(Viewport.rect.height * 0.5f, TotalDataHeight - (Viewport.rect.height * 0.5f));
|
||||
}
|
||||
|
||||
private void SetRecycleViewBounds(bool extendPoolIfGrown)
|
||||
{
|
||||
RecycleViewBounds = new Vector2(Viewport.MinY() + HalfThreshold, Viewport.MaxY() - HalfThreshold);
|
||||
|
||||
if (extendPoolIfGrown && prevViewportHeight < Viewport.rect.height && prevViewportHeight != 0.0f)
|
||||
CheckExtendCellPool();
|
||||
|
||||
prevViewportHeight = Viewport.rect.height;
|
||||
}
|
||||
|
||||
// Cell pool
|
||||
|
||||
public void ReturnCells()
|
||||
{
|
||||
if (CellPool.Any())
|
||||
{
|
||||
foreach (var cell in CellPool)
|
||||
{
|
||||
DataSource.OnCellReturned(cell);
|
||||
Pool<T>.Return(cell);
|
||||
}
|
||||
CellPool.Clear();
|
||||
}
|
||||
private CellInfo _cellInfo = new CellInfo();
|
||||
|
||||
bottomDataIndex = -1;
|
||||
topPoolIndex = 0;
|
||||
bottomPoolIndex = 0;
|
||||
public IEnumerator<CellInfo> GetPoolEnumerator()
|
||||
{
|
||||
int cellIdx = topPoolIndex;
|
||||
int dataIndex = TopDataIndex;
|
||||
int iterated = 0;
|
||||
while (iterated < CellPool.Count)
|
||||
{
|
||||
_cellInfo.cellIndex = cellIdx;
|
||||
_cellInfo.dataIndex = dataIndex;
|
||||
yield return _cellInfo;
|
||||
|
||||
cellIdx++;
|
||||
if (cellIdx >= CellPool.Count)
|
||||
cellIdx = 0;
|
||||
|
||||
dataIndex++;
|
||||
iterated++;
|
||||
}
|
||||
}
|
||||
|
||||
private void CreateCellPool()
|
||||
{
|
||||
ReturnCells();
|
||||
//ReleaseCells();
|
||||
|
||||
CheckDataSourceCountChange(out _);
|
||||
|
||||
@ -256,8 +242,8 @@ namespace UnityExplorer.UI.Widgets
|
||||
bottomPoolIndex++;
|
||||
|
||||
var cell = Pool<T>.Borrow();
|
||||
DataSource.OnCellBorrowed(cell);
|
||||
CellPool.Add(cell);
|
||||
DataSource.OnCellBorrowed(cell);
|
||||
cell.Rect.SetParent(ScrollRect.content, false);
|
||||
|
||||
currentPoolCoverage += PrototypeHeight;
|
||||
@ -266,26 +252,11 @@ namespace UnityExplorer.UI.Widgets
|
||||
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);
|
||||
}
|
||||
|
||||
private void SetRecycleViewBounds(bool extendPoolIfGrown)
|
||||
{
|
||||
RecycleViewBounds = new Vector2(Viewport.MinY() + HalfThreshold, Viewport.MaxY() - HalfThreshold);
|
||||
|
||||
if (extendPoolIfGrown && prevViewportHeight < Viewport.rect.height && prevViewportHeight != 0.0f)
|
||||
CheckExtendCellPool();
|
||||
|
||||
prevViewportHeight = Viewport.rect.height;
|
||||
}
|
||||
|
||||
private bool CheckExtendCellPool()
|
||||
{
|
||||
CheckDataSourceCountChange(out _);
|
||||
CheckDataSourceCountChange();
|
||||
|
||||
var requiredCoverage = Math.Abs(RecycleViewBounds.y - RecycleViewBounds.x);
|
||||
var currentCoverage = CellPool.Count * PrototypeHeight;
|
||||
@ -317,7 +288,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
}
|
||||
}
|
||||
|
||||
RefreshCells(true);
|
||||
RefreshCells(true, true);
|
||||
|
||||
//ExplorerCore.Log("Anchor: " + Content.localPosition.y + ", prev: " + prevAnchor);
|
||||
//ExplorerCore.Log("Height: " + Content.rect.height + ", prev:" + prevHeight);
|
||||
@ -343,27 +314,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
// Refresh methods
|
||||
|
||||
private CellInfo _cellInfo = new CellInfo();
|
||||
|
||||
public IEnumerator<CellInfo> GetPoolEnumerator()
|
||||
{
|
||||
int cellIdx = topPoolIndex;
|
||||
int dataIndex = TopDataIndex;
|
||||
int iterated = 0;
|
||||
while (iterated < CellPool.Count)
|
||||
{
|
||||
_cellInfo.cellIndex = cellIdx;
|
||||
_cellInfo.dataIndex = dataIndex;
|
||||
yield return _cellInfo;
|
||||
|
||||
cellIdx++;
|
||||
if (cellIdx >= CellPool.Count)
|
||||
cellIdx = 0;
|
||||
|
||||
dataIndex++;
|
||||
iterated++;
|
||||
}
|
||||
}
|
||||
private bool CheckDataSourceCountChange() => CheckDataSourceCountChange(out _);
|
||||
|
||||
private bool CheckDataSourceCountChange(out bool shouldJumpToBottom)
|
||||
{
|
||||
@ -428,7 +379,9 @@ namespace UnityExplorer.UI.Widgets
|
||||
Content.anchoredPosition += Vector2.up * diff;
|
||||
}
|
||||
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
if (andReloadFromDataSource)
|
||||
LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
|
||||
SetScrollBounds();
|
||||
ScrollRect.UpdatePrevData();
|
||||
}
|
||||
@ -456,7 +409,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
private void OnValueChangedListener(Vector2 val)
|
||||
{
|
||||
if (WritingLocked || !m_initialized)
|
||||
if (WritingLocked || DataSource == null)
|
||||
return;
|
||||
|
||||
if (InputManager.MouseScrollDelta != Vector2.zero)
|
||||
@ -529,8 +482,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
topPoolIndex = (topPoolIndex + 1) % CellPool.Count;
|
||||
}
|
||||
|
||||
//LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
|
||||
return -recycledheight;
|
||||
}
|
||||
|
||||
@ -572,8 +523,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
bottomPoolIndex = (bottomPoolIndex - 1 + CellPool.Count) % CellPool.Count;
|
||||
}
|
||||
|
||||
//LayoutRebuilder.ForceRebuildLayoutImmediate(Content);
|
||||
|
||||
return recycledheight;
|
||||
}
|
||||
|
||||
@ -624,7 +573,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
private void OnSliderValueChanged(float val)
|
||||
{
|
||||
if (this.WritingLocked || !m_initialized)
|
||||
if (this.WritingLocked || DataSource == null)
|
||||
return;
|
||||
this.WritingLocked = true;
|
||||
|
||||
|
@ -72,7 +72,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
RefreshData(true, true);
|
||||
}
|
||||
|
||||
public void RefreshData(bool andReload = false, bool hardReload = false)
|
||||
public void RefreshData(bool andReload = false, bool jumpToTop = false)
|
||||
{
|
||||
displayedObjects.Clear();
|
||||
|
||||
@ -86,10 +86,10 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
if (andReload)
|
||||
{
|
||||
if (!hardReload)
|
||||
ScrollPool.RefreshCells(true);
|
||||
if (!jumpToTop)
|
||||
ScrollPool.Refresh(true);
|
||||
else
|
||||
ScrollPool.Rebuild();
|
||||
ScrollPool.Refresh(true, true);
|
||||
}
|
||||
}
|
||||
|
||||
@ -172,7 +172,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
cell.OnExpandToggled += ToggleExpandCell;
|
||||
}
|
||||
|
||||
public void OnCellReturned(TransformCell cell)
|
||||
public void ReleaseCell(TransformCell cell)
|
||||
{
|
||||
cell.OnExpandToggled -= ToggleExpandCell;
|
||||
}
|
||||
|
@ -321,10 +321,9 @@
|
||||
<Compile Include="Inspectors_OLD\InteractiveValues\InteractiveString.cs" />
|
||||
<Compile Include="Inspectors_OLD\InteractiveValues\InteractiveValue.cs" />
|
||||
<Compile Include="UI\Widgets\ButtonRef.cs" />
|
||||
<Compile Include="UI\Panels\ObjectExplorer\ObjectSearch.cs" />
|
||||
<Compile Include="UI\Panels\ObjectExplorer\SceneExplorer.cs" />
|
||||
<Compile Include="UI\ObjectExplorer\ObjectSearch.cs" />
|
||||
<Compile Include="UI\ObjectExplorer\SceneExplorer.cs" />
|
||||
<Compile Include="UI\Widgets\ScrollPool\DataHeightCache.cs" />
|
||||
<Compile Include="UI\Widgets\ScrollPool\CellViewHolder.cs" />
|
||||
<Compile Include="UI\Widgets\ScrollPool\ICell.cs" />
|
||||
<Compile Include="UI\Widgets\ScrollPool\IPoolDataSource.cs" />
|
||||
<Compile Include="UI\Widgets\ScrollPool\ScrollPool.cs" />
|
||||
|
Loading…
x
Reference in New Issue
Block a user