DGJ 1 month ago
parent
commit
d90519f322
2 changed files with 14 additions and 9 deletions
  1. 6 6
      Assets/Page/Scripts/PageBtnControl.cs
  2. 8 3
      Assets/Page/Scripts/PageItem.cs

+ 6 - 6
Assets/Page/Scripts/PageBtnControl.cs

@@ -64,10 +64,7 @@ public class PageBtnControl : MonoBehaviour
                 listPageItems[i].UpdatePage(i + 1);
             }
 
-            for (int i = listPageItems.Count - 1; i > allPage - listPageItems.Count; i++)
-            {
-                listPageItems[i].gameObject.SetActive(false);
-            }
+          
 
             if (allPage > 10)
             {
@@ -153,12 +150,15 @@ public class PageBtnControl : MonoBehaviour
         }
         curretPage = pageNum;
 
+
+
         for (int i = 0; i < listPageItems.Count; i++)
         {
-            if(listPageItems[i].gameObject.activeSelf&&listPageItems[i].page == curretPage)
+            listPageItems[i].CloseShowUI();
+            if (listPageItems[i].gameObject.activeSelf&&listPageItems[i].page == curretPage)
             {
                 listPageItems[i].ShowUI();
-                break;
+               
             }
         }
      

+ 8 - 3
Assets/Page/Scripts/PageItem.cs

@@ -15,7 +15,7 @@ public class PageItem : MonoBehaviour
     public Image image;
     private void Start()
     {
-        pageBtnControl =  transform.parent.gameObject.GetComponent<PageBtnControl>();
+       // pageBtnControl =  transform.parent.gameObject.GetComponent<PageBtnControl>();
         image = transform.GetComponent<Image>();
         transform.GetComponent<Button>().onClick.AddListener(OnClick);
         page = itemNum;
@@ -25,13 +25,13 @@ public class PageItem : MonoBehaviour
     {
         this.page = Page;
         text.text = page.ToString();
-        image.color = Color.white;
+       // image.color = Color.white;
     }
 
     public void UpdateString( string str)
     {
         text.text = str;
-        image.color = Color.white;
+      //  image.color = Color.white;
         this.page = -1;
     }
 
@@ -52,4 +52,9 @@ public class PageItem : MonoBehaviour
     {
         image.color = Color.blue;
     }
+
+    public void CloseShowUI()
+    {
+        image.color = Color.white;
+    }
 }