From 4ee70025c0df1bd7382991b590386990c89e1235 Mon Sep 17 00:00:00 2001 From: LiRuoChen <571244399@qq.com> Date: Thu, 4 Jun 2026 15:03:32 +0800 Subject: [PATCH] =?UTF-8?q?=E5=B0=86=E9=A1=B5=E9=9D=A2=E5=A7=94=E6=89=98?= =?UTF-8?q?=E6=94=B9=E4=B8=BA=E5=B1=9E=E6=80=A7=EF=BC=8C=E4=B8=8D=E8=83=BD?= =?UTF-8?q?=E5=86=8Dawake=E9=98=B6=E6=AE=B5=E5=88=9B=E5=BB=BA=E4=BA=86?= =?UTF-8?q?=EF=BC=8C=E4=BC=9A=E5=AF=BC=E8=87=B4=E7=94=9F=E5=91=BD=E5=91=A8?= =?UTF-8?q?=E6=9C=9F=E9=97=AE=E9=A2=98=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Runtime/FlipPage/FlipPageComponentManager.cs | 4 +- .../FlipPage/XericFlipPageIndexVesselBase.cs | 38 +++++++++++++------ 2 files changed, 30 insertions(+), 12 deletions(-) diff --git a/Runtime/FlipPage/FlipPageComponentManager.cs b/Runtime/FlipPage/FlipPageComponentManager.cs index 2765db8..39f7335 100644 --- a/Runtime/FlipPage/FlipPageComponentManager.cs +++ b/Runtime/FlipPage/FlipPageComponentManager.cs @@ -149,6 +149,8 @@ namespace XericUI.FlipPage } } + protected override Func HowToCreatPageInfo => () => new PageComponentInfo(); + #endregion #region 类内类型 @@ -217,7 +219,7 @@ namespace XericUI.FlipPage protected override void Awake() { // 使用默认的 - HowToCreatPageInfo = () => new PageComponentInfo(); + base.Awake(); diff --git a/Runtime/FlipPage/XericFlipPageIndexVesselBase.cs b/Runtime/FlipPage/XericFlipPageIndexVesselBase.cs index cc2b8da..50970cc 100644 --- a/Runtime/FlipPage/XericFlipPageIndexVesselBase.cs +++ b/Runtime/FlipPage/XericFlipPageIndexVesselBase.cs @@ -76,8 +76,20 @@ namespace XericUI.FlipPage /// /// Ò³Ãæ¶ÔÏ󳨣¬¶ÔÏ󳨽ö¹ÜÀíÒ³Ãæ±¾Éí£¬²»²ÎÓëÈκÎÊý¾ÝÈÝÆ÷µÄ¹ÜÀí¡£ /// - protected ObjectPool PageInfoPool = null; - public Func HowToCreatPageInfo = () => throw new Exception("ÐèÒª·­Ò³¹ÜÀíÆ÷ʵÏÖÏàÓ¦µÄÒ³Ãæ´´½¨Âß¼­£¬²¢ÖØÐ´Ìí¼ÓĬÈÏÊý¾Ý·½·¨ºó²Å¿ÉÒÔʹÓá£"); + private ObjectPool _pageInfoPool = null; + + protected ObjectPool PageInfoPool + { + get + { + if (_pageInfoPool != null) + return _pageInfoPool; + _pageInfoPool = new ObjectPool(CreatPageInfo, GetPageInfo, ReleasePageInfo, DestroyPageInfo); + return _pageInfoPool; + } + } + + protected virtual Func HowToCreatPageInfo => () => throw new Exception("ÐèÒª·­Ò³¹ÜÀíÆ÷ʵÏÖÏàÓ¦µÄÒ³Ãæ´´½¨Âß¼­£¬²¢ÖØÐ´Ìí¼ÓĬÈÏÊý¾Ý·½·¨ºó²Å¿ÉÒÔʹÓá£"); /// /// µ±Ç°Ñ¡ÖеÄÒ³ÃæË÷Òý @@ -148,7 +160,6 @@ namespace XericUI.FlipPage protected override void Awake() { base.Awake(); - PageInfoPool = new ObjectPool(CreatPageInfo, GetPageInfo, ReleasePageInfo, DestroyPageInfo); } protected override void Start() @@ -277,6 +288,7 @@ namespace XericUI.FlipPage CurrentPageNode = null; return; } + CurrentPageNode = nextPage; } } @@ -351,7 +363,7 @@ namespace XericUI.FlipPage { if (pageInfo == null) pageInfo = PageInfoPool.Get(); - + if (isFirstOtherwiseLast) { // Ìí¼ÓÒ³Ãæ(Ò³ÃæÏ±êĬÈÏ0) @@ -366,6 +378,7 @@ namespace XericUI.FlipPage // Ìí¼ÓÒ³Ãæ _pageInfos.AddLast(pageInfo); } + // GetPageInfo(pageInfo); // Ö´ÐÐÒ³ÃæÉúÃüÖÜÆÚ pageInfo.OnPageCreated(this); @@ -405,7 +418,7 @@ namespace XericUI.FlipPage tempPage = tempPage.Next; tempPage.Value.pageNumber = tempPageNumber++; } - + // Ë¢ÐÂÒ³Ãæ FlipPage(currentPageIndex, true); } @@ -452,10 +465,11 @@ namespace XericUI.FlipPage pageInfo.ItemInfos.Clear(); PageInfoPool.Release(pageInfo); } + ListPool.Release(tempPageInfo); // Çå¿Õ³Ø if (resetPool) - PageInfoPool.Clear(); + PageInfoPool?.Clear(); // ÖØÖõ±Ç°Ò³Ãæ CurrentPageNode = null; currentPageIndex = 0; @@ -547,6 +561,7 @@ namespace XericUI.FlipPage Debug.LogError($"Á÷³Ì´íÎó£¬Ò³Ãæ³¢ÊÔÖØ¸´»ñÈ¡£¬Çë¼ì²é´úÂëÁ÷³Ì({info.GetHashCode():X16})\n_>{info.name}"); return; } + info.OnPageCreated(this); return; } @@ -563,6 +578,7 @@ namespace XericUI.FlipPage Debug.LogError("Á÷³Ì´íÎó£¬Ò³Ãæ³¢ÊÔÖØ¸´ÊÍ·Å£¬Çë¼ì²é´úÂëÁ÷³Ì"); return; } + if (CurrentPageNode != null && Currentpage == info) { info.OnPageInvisible(true); @@ -672,7 +688,7 @@ namespace XericUI.FlipPage /// public bool Contains(ItemInfo item) => _itemInfos.Contains(item); - + #endregion #region ÀàÄÚÀàÐÍ @@ -701,13 +717,13 @@ namespace XericUI.FlipPage [LabelText("Ò³ÃæÏîÄ¿ÐÅÏ¢")] #endif private List _itemInfos; - + public List ItemInfos { get => _itemInfos ??= ListPool.Get(); set => _itemInfos = value; } - + /// /// ´ÓÁ㿪ʼ¼ÆÊýµÄÒ³ÃæÏ±ê /// @@ -748,7 +764,7 @@ namespace XericUI.FlipPage if (ItemInfos != null) { ListPool.Release(ItemInfos); - ItemInfos = null; + ItemInfos = null; } } @@ -857,7 +873,7 @@ namespace XericUI.FlipPage protected internal abstract void OnItemInvisible(); #endregion - + public override string ToString() { return $"[{nameof(ItemInfo)}] ({name})";