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