From 2636bf475c8b4b03ee869a5db2f5fdd891ed9f97 Mon Sep 17 00:00:00 2001
From: yyl <yyl>
Date: 星期四, 04 十二月 2025 09:19:35 +0800
Subject: [PATCH] Merge branch 'master' of http://192.168.1.20:10010/r/Project_SG_scripts

---
 Main/Component/UI/EnhancedScroller/EnhancedScroller.cs |  130 +++++++++++++++++++++++++++++++++++-------
 1 files changed, 107 insertions(+), 23 deletions(-)

diff --git a/Main/Component/UI/EnhancedScroller/EnhancedScroller.cs b/Main/Component/UI/EnhancedScroller/EnhancedScroller.cs
index ac9609a..0cf4595 100644
--- a/Main/Component/UI/EnhancedScroller/EnhancedScroller.cs
+++ b/Main/Component/UI/EnhancedScroller/EnhancedScroller.cs
@@ -262,7 +262,7 @@
                         // set the vertical position
                         scrollRect.verticalNormalizedPosition = 1f - (_scrollPosition / _ScrollSize);
                         //杩欓噷瑕佹敞鎰忥紝濡傛灉闆嗗悎杩涜杩囧鍒讹紝閭d箞杩欓噷鐨刜scrollSize涔熶竴鏍蜂細姣斿師鏉ョ殑澧炲姞锛屽洜涓篲ScrollSize姘歌繙姣攃ontent鐨勬�诲ぇ灏忓皬涓�涓彲瑙嗗尯澶у皬
-                        
+
                     }
                     else
                     {
@@ -379,9 +379,9 @@
         /// The scroller should only be moving one one axix.
         /// </summary>
         public float LinearVelocity //瀹炶川涓婃槸鎿嶄綔ScrollRect.velocity
-                       //Get : 灏嗗悜閲忚浆涓篺loat绫诲瀷
-                       //Set锛氱敤涓�涓猣loat绫诲瀷鏋勯�犱竴涓浉搴旂殑鍚戦噺
-        //澶栭儴鏂规硶鍙互閫氳繃璁块棶杩欎釜灞炴�ф潵浣縮croll杩愬姩璧锋潵
+                                    //Get : 灏嗗悜閲忚浆涓篺loat绫诲瀷
+                                    //Set锛氱敤涓�涓猣loat绫诲瀷鏋勯�犱竴涓浉搴旂殑鍚戦噺
+                                    //澶栭儴鏂规硶鍙互閫氳繃璁块棶杩欎釜灞炴�ф潵浣縮croll杩愬姩璧锋潵
         {
             get
             {
@@ -450,7 +450,7 @@
                 return _activeCellViewsStartIndex % NumberOfCells;
             }
         }
-        
+
         /// <summary>
         /// This is the last data index showing in the scroller's visible area
         /// </summary>
@@ -462,8 +462,10 @@
             }
         }
 
-        public int ActiveCellCnt {
-            get {
+        public int ActiveCellCnt
+        {
+            get
+            {
                 return _activeCellViews.Count;
             }
         }
@@ -512,7 +514,7 @@
                 var go = Instantiate(cellPrefab.gameObject);
                 cellView = go.GetComponent<EnhancedScrollerCellView>();
                 cellView.transform.SetParent(_container);
-                
+
             }
             Vector3 pos = cellView.transform.localPosition;
             if (pos.x == float.NaN || pos.y == float.NaN)
@@ -881,9 +883,12 @@
         /// Cached reference to the scrollRect
         /// </summary>
         private ScrollRect m_ScrollRect;
-        public ScrollRect scrollRect {
-            get {
-                if (m_ScrollRect == null) {
+        public ScrollRect scrollRect
+        {
+            get
+            {
+                if (m_ScrollRect == null)
+                {
                     m_ScrollRect = this.GetComponent<ScrollRect>();
                 }
                 return m_ScrollRect;
@@ -1075,10 +1080,10 @@
         /// of the scroller
         /// </summary>
         public float _ScrollSize//杩欓噷骞朵笉鏄寚scrllrect鐨勫ぇ灏忥紝鑰屾槸鎸囩湡姝e湪婊戝姩鐨勫尯鍩熺殑澶у皬
-                                /*scrollrect鐨刵ormallizePosition瀹為檯涓婂氨鏄繖涓湡姝h兘婊戝姩鐨勫尯鍩熺殑澶у皬
-                                 * 鍦ㄦ粦鍔ㄨ繃绋嬩腑褰掍竴鍖栫殑鍊硷紝鑰岃繖涓ぇ灏忓氨鏄墍鏈夊瓙鐗╀綋鐨勫ぇ灏忎笌鍙鍖栧尯鍩熺殑宸�
-                                 * 褰揷ontent鐨勫ぇ灏忕瓑浜庢墍鏈夊瓙鐗╀綋鐨勫ぇ灏忔椂锛屽氨鍙互绠�鍖栨搷浣滅洿鎺ョ敤content鐨勫ぇ灏忔潵浠f浛
-                                 */
+        /*scrollrect鐨刵ormallizePosition瀹為檯涓婂氨鏄繖涓湡姝h兘婊戝姩鐨勫尯鍩熺殑澶у皬
+         * 鍦ㄦ粦鍔ㄨ繃绋嬩腑褰掍竴鍖栫殑鍊硷紝鑰岃繖涓ぇ灏忓氨鏄墍鏈夊瓙鐗╀綋鐨勫ぇ灏忎笌鍙鍖栧尯鍩熺殑宸�
+         * 褰揷ontent鐨勫ぇ灏忕瓑浜庢墍鏈夊瓙鐗╀綋鐨勫ぇ灏忔椂锛屽氨鍙互绠�鍖栨搷浣滅洿鎺ョ敤content鐨勫ぇ灏忔潵浠f浛
+         */
         {
             get
             {
@@ -1090,7 +1095,7 @@
                         return 0;
 
                 }
-                  
+
                 else
                 {
                     if (_container != null && _scrollRectTransform != null)
@@ -1098,9 +1103,88 @@
                     else
                         return 0;
                 }
-                   
+
             }
         }
+
+        // 浠呰亰澶╁姛鑳戒娇鐢�
+        public void AddHeight(bool keepPosition, float height)
+        {
+            // 濡傛灉鍚敤寰幆锛屽洖閫�鍒板畬鏁寸殑 _Resize锛屽洜涓哄惊鐜�昏緫澶嶆潅
+            if (loop)
+            {
+                _Resize(keepPosition);
+                return;
+            }
+
+            // 缂撳瓨鍘熷浣嶇疆
+            var originalScrollPosition = _scrollPosition;
+
+            int cellCount = NumberOfCells;
+            if (cellCount == 0)
+            {
+                // 娌℃湁鍗曞厓鏍硷紝璋冪敤 _Resize 澶勭悊
+                _Resize(keepPosition);
+                return;
+            }
+
+            int newCellIndex = cellCount - 1; // 鏂板崟鍏冩牸鐨勭储寮�
+
+            // 妫�鏌ュ唴閮ㄦ暟缁勬槸鍚︿竴鑷达細_cellViewSizeArray 搴旇宸茬粡鍖呭惈浜嗛櫎鏂板崟鍏冩牸澶栫殑鎵�鏈夊崟鍏冩牸
+            if (_cellViewSizeArray.Count != newCellIndex)
+            {
+                // 涓嶄竴鑷达紝鍥為��鍒板畬鏁撮噸缃�
+                _Resize(keepPosition);
+                return;
+            }
+
+            // 璁$畻鏂板崟鍏冩牸鐨勫ぇ灏忥紙鍖呮嫭闂磋窛锛�
+            float newSize = height;
+            newSize += spacing;
+
+            // 娣诲姞鍒板ぇ灏忔暟缁�
+            _cellViewSizeArray.Add(newSize);
+
+            // 鏇存柊鍋忕Щ鏁扮粍
+            float previousOffset = (_cellViewOffsetArray.Count > 0) ? _cellViewOffsetArray.Last() : 0;
+            _cellViewOffsetArray.Add(previousOffset + newSize);
+
+            // 璁剧疆娲诲姩鍗曞厓鏍煎鍣ㄧ殑澶у皬
+            if (scrollDirection == ScrollDirectionEnum.Vertical)
+                _container.sizeDelta = new Vector2(_container.sizeDelta.x, _cellViewOffsetArray.Last() + padding.top + padding.bottom);
+            else
+                _container.sizeDelta = new Vector2(_cellViewOffsetArray.Last() + padding.left + padding.right, _container.sizeDelta.y);
+
+            // 閲嶅缓鍙鍗曞厓鏍�
+            _ResetVisibleCellViews();
+            if (this.Delegate != null)
+            {
+                this.Delegate.OnRebuildComplete();
+            }
+
+            // 濡傛灉闇�瑕佷繚鎸佸師濮嬩綅缃�
+            if (keepPosition)
+            {
+                ScrollPosition = originalScrollPosition;
+            }
+            else
+            {
+                ScrollPosition = 0;
+            }
+
+            // 璁剧疆婊氬姩鏉″彲瑙佹��
+            ScrollbarVisibility = scrollbarVisibility;
+
+            if (!m_IsLoadAll)
+            {
+                m_IsLoadAll = true;
+                if (OnFirstLoadAllEvent != null)
+                {
+                    OnFirstLoadAllEvent();
+                }
+            }
+        }
+
 
         /// <summary>
         /// This function will create an internal list of sizes and offsets to be used in all calculations.
@@ -1157,7 +1241,7 @@
             {
                 _loopFirstScrollPosition = GetScrollPositionForCellViewIndex(_loopFirstCellIndex, CellViewPositionEnum.Before) + (spacing * 0.5f);
                 _loopLastScrollPosition = GetScrollPositionForCellViewIndex(_loopLastCellIndex, CellViewPositionEnum.After) - ScrollRectSize + (spacing * 0.5f);
-               
+
 
                 _loopFirstJumpTrigger = _loopFirstScrollPosition - ScrollRectSize;
                 _loopLastJumpTrigger = _loopLastScrollPosition + ScrollRectSize;
@@ -1399,10 +1483,10 @@
         /// <param name="cellIndex">The index of the cell view</param>
         /// <param name="listPosition">Whether to add the cell to the beginning or the end</param>
         private void _AddCellView(int cellIndex, ListPositionEnum listPosition)
-        {   
+        {
             //閫氳繃鏌愪釜绱㈠紩娣诲姞锛堜粠缂撳啿姹犱腑鍙栵級瀛愮墿浣撳埌_activeCellViews闆嗗悎涓紝骞惰Е鍙戠浉鍏充簨浠�
             //杩欎釜鏂规硶鏈韩涔熶細鏍规嵁浼犺繃鏉ョ殑绱㈠紩鏉ュ垵濮嬪寲CellView
-             
+
             if (NumberOfCells == 0) return;
 
             // get the dataIndex. Modulus is used in case of looping so that the first set of cells are ignored
@@ -1662,7 +1746,7 @@
             _lastScrollbarVisibility = scrollbarVisibility;
             //涓�浜涘彉閲忚繘琛屼簡鍒濆鍖�
 
-            if(OnCompLoad!=null) OnCompLoad();
+            if (OnCompLoad != null) OnCompLoad();
             inited = true;
         }
 
@@ -1672,7 +1756,7 @@
             {
                 // if the reload flag is true, then reload the data
                 ReloadData();//鐞嗚涓婁笉鐢ㄥ湪澶栭儴璋冪敤ReloadData()鍥犱负褰撴垚鍔熻祴鍊糄elegate鍚庤繖涓柟娉曞氨浼氭墽琛屼竴娆�
-                               //浣嗗鏋滄兂鍦╱pdate涔嬪墠鎵ц灏变富鍔ㄨ皟鐢≧eloadData()
+                             //浣嗗鏋滄兂鍦╱pdate涔嬪墠鎵ц灏变富鍔ㄨ皟鐢≧eloadData()
             }
 
             // if the scroll rect size has changed and looping is on,
@@ -1770,7 +1854,7 @@
              */
 
         }
-        
+
         /// <summary>
         /// This is fired by the tweener when the snap tween is completed
         /// </summary>

--
Gitblit v1.8.0