翻页/滚动列表:没有页、没有池配置时不再抛空引用
- 翻页:总页数为 0 时 FlipsPage 会去访问第 0 页的节点(没有),先判 TotalPageCount > 0。 - 滚动列表:childrenPool 是后来加的字段,老预制体里为空;无条件 Initialize 会在 Start 抛 ArgumentNullException,没配预制体就跳过(不池化照常滚动)。
This commit is contained in:
@@ -169,7 +169,10 @@ namespace XericUI.FlipPage
|
||||
{
|
||||
base.Start();
|
||||
|
||||
FlipPage(currentPageIndex);
|
||||
// 一页都还没有时不要翻(页通常是运行期才加进来的):原来会走一遍
|
||||
// “索引0下的节点不存在(总数0页)” 并报一条 Error,启动日志里不该有它。
|
||||
if (TotalPageCount > 0)
|
||||
FlipPage(currentPageIndex);
|
||||
}
|
||||
|
||||
protected override void OnDestroy()
|
||||
|
||||
@@ -248,7 +248,11 @@ namespace XericUI.OverrideLayout
|
||||
protected override void Start()
|
||||
{
|
||||
base.Start();
|
||||
childrenPool.Initialize();
|
||||
// childrenPool 是这个插件后来加的格:老预制体里根本没有这一项(加载后是空池),
|
||||
// 无条件 Initialize 会在 Start 里抛 ArgumentNullException。没配预制体就跳过——
|
||||
// 不用对象池的滚动列表照常滚动,只是没有池化子项。
|
||||
if (childrenPool != null && childrenPool.Prefab != null)
|
||||
childrenPool.Initialize();
|
||||
}
|
||||
|
||||
protected override void SetContentAnchoredPosition(Vector2 position)
|
||||
|
||||
Reference in New Issue
Block a user