Browse Source

修改虚拟列表

lzx 22 hours ago
parent
commit
b22ed6cd74

+ 17 - 8
Assets/Scripts/GameUI/ScorolList/ScrollList.cs

@@ -101,7 +101,7 @@ public class ScrollList : MonoBehaviour, IScrollListContent
     /// <param name="scrollListContent"></param>
     /// <param name="scrollListContent"></param>
     /// <param name="maxSize"></param>
     /// <param name="maxSize"></param>
     /// <param name="startIndex"></param>
     /// <param name="startIndex"></param>
-    public async CTask Init(IScrollListContent scrollListContent, int maxSize, int startIndex = 0)
+    public async CTask Init(IScrollListContent scrollListContent, int maxSize, int startIndex = 0, bool t = false)
     {
     {
         if (startIndex < 0)
         if (startIndex < 0)
         {
         {
@@ -166,7 +166,17 @@ public class ScrollList : MonoBehaviour, IScrollListContent
                 currIndex = startIndex;
                 currIndex = startIndex;
 
 
                 // Vector2 targetSizeDelta = CalculateTargetSizeDelta(startIndex);
                 // Vector2 targetSizeDelta = CalculateTargetSizeDelta(startIndex);
-                Vector2 targetSizeDelta = CalculateBottomSizeDelta(startIndex);
+                Vector2 targetSizeDelta;
+
+                if (t)
+                {
+                    targetSizeDelta = CalculateBottomSizeDelta(maxSize);
+                }
+                else
+                {
+                    targetSizeDelta = CalculateBottomSizeDelta(startIndex);
+                }
+
                 targetSizeDelta += new Vector2(0, bottom);
                 targetSizeDelta += new Vector2(0, bottom);
                 lasetPos = CalculateTargetPosition(startIndex);
                 lasetPos = CalculateTargetPosition(startIndex);
                 myRectTransform.sizeDelta = new Vector2(sizeData.x, targetSizeDelta.y);
                 myRectTransform.sizeDelta = new Vector2(sizeData.x, targetSizeDelta.y);
@@ -229,7 +239,6 @@ public class ScrollList : MonoBehaviour, IScrollListContent
         {
         {
             HindWidget();
             HindWidget();
         }
         }
-        
     }
     }
 
 
     protected async CTask<IScorllListWidget> Cread(int index, bool isUp)
     protected async CTask<IScorllListWidget> Cread(int index, bool isUp)
@@ -650,7 +659,7 @@ public class ScrollList : MonoBehaviour, IScrollListContent
         float miny = pos.y - (root.rect.size.y * root.pivot.y);
         float miny = pos.y - (root.rect.size.y * root.pivot.y);
         float maxx = pos.x + (root.rect.size.x * (1 - root.pivot.x));
         float maxx = pos.x + (root.rect.size.x * (1 - root.pivot.x));
         float maxy = pos.y + (root.rect.size.y * (1 - root.pivot.y));
         float maxy = pos.y + (root.rect.size.y * (1 - root.pivot.y));
-        
+
         Vector2 rootPos = posint;
         Vector2 rootPos = posint;
 
 
 
 
@@ -670,10 +679,10 @@ public class ScrollList : MonoBehaviour, IScrollListContent
                 // {
                 // {
                 //     isHind = true;
                 //     isHind = true;
                 // }
                 // }
-                
+
                 //不依赖widget尺寸大小
                 //不依赖widget尺寸大小
-                if (p.y > miny  - 200 &&
-                    p.y < maxy  + 200)
+                if (p.y > miny - 200 &&
+                    p.y < maxy + 200)
                 {
                 {
                     isHind = true;
                     isHind = true;
                 }
                 }
@@ -842,7 +851,7 @@ public class ScrollList : MonoBehaviour, IScrollListContent
             int visibleRows = Mathf.CeilToInt(viewportHeight / itemHeight); // 向上取整
             int visibleRows = Mathf.CeilToInt(viewportHeight / itemHeight); // 向上取整
 
 
             // 计算最低端索引
             // 计算最低端索引
-            int bottomIndex = Mathf.Min(targetIndex + visibleRows * Page.y, _maxSize - 1);
+            int bottomIndex = Mathf.Min(targetIndex + visibleRows * Page.y, _maxSize );
             int totalRows = (bottomIndex + Page.y - 1) / Page.y; // 从 0 到 bottomIndex 的行数
             int totalRows = (bottomIndex + Page.y - 1) / Page.y; // 从 0 到 bottomIndex 的行数
 
 
             if (!isCustomizeHeight)
             if (!isCustomizeHeight)

+ 3 - 4
Assets/Scripts/GameUI/UI/TowerPanel/TowerPanel.cs

@@ -114,15 +114,14 @@ namespace Fort23.Mono
             else
             else
             {
             {
                 ulockTowerInfoConfig = ConfigComponent.Instance.Get<TowerInfoConfig>(ulockId);
                 ulockTowerInfoConfig = ConfigComponent.Instance.Get<TowerInfoConfig>(ulockId);
-             
             }
             }
 
 
             Slider_Stage.GetComponent<RectTransform>().sizeDelta = size;
             Slider_Stage.GetComponent<RectTransform>().sizeDelta = size;
 
 
-            Slider_Stage.value = (float)(ulockTowerInfoConfig.level-1) /
-                                 (towerInfoConfigps.Count-1 );
+            Slider_Stage.value = (float)(ulockTowerInfoConfig.level - 1) /
+                                 (towerInfoConfigps.Count - 1);
 
 
-            Content.Init(this, towerInfoConfigps.Count - 1, towerInfoConfigps.Count - 1 - ulockTowerInfoConfig.level);
+            Content.Init(this, towerInfoConfigps.Count, towerInfoConfigps.Count - 1 - ulockTowerInfoConfig.level, true);
         }
         }
 
 
         public static async CTask OpenPanel(int id)
         public static async CTask OpenPanel(int id)