mirror of
https://github.com/sinai-dev/UnityExplorer.git
synced 2025-01-06 01:23:31 +08:00
Cleanup scroll pool, fix some minor things
This commit is contained in:
parent
012994ed02
commit
feb86a77fd
@ -73,9 +73,8 @@ namespace UnityExplorer.UI.Panels
|
||||
contentHolder.SetActive(false);
|
||||
contentHolder.transform.SetParent(this.content.transform, false);
|
||||
|
||||
GameObject.DontDestroyOnLoad(contentHolder);
|
||||
ExplorerCore.Log("Creating dummy objects");
|
||||
for (int i = 0; i < 10; i++)
|
||||
for (int i = 0; i < 150; i++)
|
||||
{
|
||||
dummyContents.Add(CreateDummyContent());
|
||||
}
|
||||
|
@ -168,13 +168,12 @@ namespace UnityExplorer.UI.Utility
|
||||
{
|
||||
if ((type = GetResizeType(resizePos)) != ResizeTypes.NONE)
|
||||
OnHoverResize(type);
|
||||
else if (WasHoveringResize)
|
||||
OnHoverResizeEnd();
|
||||
handledInstanceThisFrame = true;
|
||||
}
|
||||
else if (WasHoveringResize)
|
||||
{
|
||||
OnHoverResizeEnd();
|
||||
handledInstanceThisFrame = true;
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
||||
|
@ -28,7 +28,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
{
|
||||
this.sisterCache = sisterCache;
|
||||
|
||||
ExplorerCore.Log("Creating backup height cache, this count: " + scrollPool.DataSource.ItemCount);
|
||||
TakeFromSister(scrollPool.DataSource.ItemCount);
|
||||
}
|
||||
|
||||
@ -79,7 +78,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
public void TakeFromSister(int count)
|
||||
{
|
||||
for (int i = 0, i < count; i++)
|
||||
for (int i = 0; i < count; i++)
|
||||
Add(sisterCache[ScrollPool.DataSource.GetRealIndexOfTempIndex(i)]);
|
||||
}
|
||||
|
||||
|
@ -250,8 +250,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
DisableTempCache();
|
||||
}
|
||||
|
||||
bool ret = false;
|
||||
|
||||
CheckDataSourceCountChange(out _);
|
||||
|
||||
var requiredCoverage = Math.Abs(RecycleViewBounds.y - RecycleViewBounds.x);
|
||||
@ -259,7 +257,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
int cellsRequired = (int)Math.Ceiling((decimal)(requiredCoverage - currentCoverage) / (decimal)PrototypeHeight);
|
||||
if (cellsRequired > 0 || forceRecreate)
|
||||
{
|
||||
ret = true;
|
||||
WritingLocked = true;
|
||||
|
||||
// Disable cells so DataSource can handle its content if need be
|
||||
@ -285,9 +282,11 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
SetScrollBounds();
|
||||
UpdateSliderHandle(true);
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
// Refresh methods
|
||||
@ -318,7 +317,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
|
||||
private bool CheckDataSourceCountChange(out bool shouldJumpToBottom)
|
||||
{
|
||||
bool ret = false;
|
||||
shouldJumpToBottom = false;
|
||||
|
||||
int count = DataSource.ItemCount;
|
||||
@ -340,7 +338,7 @@ namespace UnityExplorer.UI.Widgets
|
||||
return false;
|
||||
}
|
||||
|
||||
return ret;
|
||||
return false;
|
||||
}
|
||||
|
||||
private void RefreshCells(bool andReloadFromDataSource, bool setSlider)
|
||||
@ -585,9 +583,6 @@ namespace UnityExplorer.UI.Widgets
|
||||
int poolStartIndex = Math.Max(0, topViewportIndex - (int)(ExtraPoolCells * 0.5f));
|
||||
poolStartIndex = Math.Min(Math.Max(0, DataSource.ItemCount - CellPool.Count), poolStartIndex);
|
||||
|
||||
bottomDataIndex = poolStartIndex + CellPool.Count - 1;
|
||||
RefreshCells(true, false);
|
||||
|
||||
var topStartPos = HeightCache[poolStartIndex].startPosition;
|
||||
|
||||
float desiredAnchor;
|
||||
@ -597,7 +592,10 @@ namespace UnityExplorer.UI.Widgets
|
||||
desiredAnchor = desiredMinY - topStartPos;
|
||||
Content.anchoredPosition = new Vector2(0, desiredAnchor);
|
||||
|
||||
UpdateSliderHandle(true);
|
||||
bottomDataIndex = poolStartIndex + CellPool.Count - 1;
|
||||
RefreshCells(true, false);
|
||||
|
||||
//UpdateSliderHandle(true);
|
||||
}
|
||||
|
||||
/// <summary>Use <see cref="UIFactory.CreateScrollPool"/></summary>
|
||||
|
Loading…
x
Reference in New Issue
Block a user