|
@@ -1,6 +1,8 @@
|
|
using System.Collections;
|
|
using System.Collections;
|
|
using System.Collections.Generic;
|
|
using System.Collections.Generic;
|
|
|
|
+using Unity.VisualScripting;
|
|
using UnityEngine;
|
|
using UnityEngine;
|
|
|
|
+using UnityEngine.Events;
|
|
using UnityEngine.UI;
|
|
using UnityEngine.UI;
|
|
|
|
|
|
public class PageBtnControl : MonoBehaviour
|
|
public class PageBtnControl : MonoBehaviour
|
|
@@ -14,23 +16,12 @@ public class PageBtnControl : MonoBehaviour
|
|
public GameObject rigNextBtn2;
|
|
public GameObject rigNextBtn2;
|
|
public GameObject leftNextBtn1;
|
|
public GameObject leftNextBtn1;
|
|
public GameObject leftNextBtn2;
|
|
public GameObject leftNextBtn2;
|
|
|
|
+ public UnityEvent<int> onValueChanged ;
|
|
|
|
|
|
private bool isRight = true;
|
|
private bool isRight = true;
|
|
private void Start()
|
|
private void Start()
|
|
{
|
|
{
|
|
|
|
|
|
- curretPage = 1;
|
|
|
|
-
|
|
|
|
-
|
|
|
|
- }
|
|
|
|
- private void Update()
|
|
|
|
- {
|
|
|
|
- if (Input.GetKeyDown(KeyCode.K))
|
|
|
|
- {
|
|
|
|
- listPageItems[0].ShowUI();
|
|
|
|
-
|
|
|
|
- InitData();
|
|
|
|
- }
|
|
|
|
}
|
|
}
|
|
public void UpdateMiddleData(int itemNum)
|
|
public void UpdateMiddleData(int itemNum)
|
|
{
|
|
{
|
|
@@ -44,6 +35,12 @@ public class PageBtnControl : MonoBehaviour
|
|
}
|
|
}
|
|
public void InitData()
|
|
public void InitData()
|
|
{
|
|
{
|
|
|
|
+ for (int i = 0; i < listPageItems.Count; i++)
|
|
|
|
+ {
|
|
|
|
+ listPageItems[i].gameObject.SetActive(true);
|
|
|
|
+ }
|
|
|
|
+ curretPage=1;
|
|
|
|
+ listPageItems[0].ShowUI();
|
|
if (allPage <10)
|
|
if (allPage <10)
|
|
{
|
|
{
|
|
for (int i = 0; i < listPageItems.Count; i++)
|
|
for (int i = 0; i < listPageItems.Count; i++)
|
|
@@ -52,10 +49,11 @@ public class PageBtnControl : MonoBehaviour
|
|
}
|
|
}
|
|
for (int i = 0; i < allPage; i++)
|
|
for (int i = 0; i < allPage; i++)
|
|
{
|
|
{
|
|
|
|
+ listPageItems[i].UpdatePage(i+1);
|
|
listPageItems[i].gameObject.SetActive(true);
|
|
listPageItems[i].gameObject.SetActive(true);
|
|
}
|
|
}
|
|
|
|
|
|
- NextBtn(false, false);
|
|
|
|
|
|
+ NextBtn();
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -72,7 +70,7 @@ public class PageBtnControl : MonoBehaviour
|
|
listPageItems[listPageItems.Count - 2].UpdateString(".....");
|
|
listPageItems[listPageItems.Count - 2].UpdateString(".....");
|
|
}
|
|
}
|
|
|
|
|
|
- NextBtn(false, true);
|
|
|
|
|
|
+ NextBtn();
|
|
}
|
|
}
|
|
listPageItems[0].ShowUI();
|
|
listPageItems[0].ShowUI();
|
|
|
|
|
|
@@ -84,6 +82,11 @@ public class PageBtnControl : MonoBehaviour
|
|
Debug.LogError(" Not Num AllPage");
|
|
Debug.LogError(" Not Num AllPage");
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+ if (pageNum < 1)
|
|
|
|
+ {
|
|
|
|
+ Debug.LogError(" Not Num AllPage");
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
Debug.Log(" Page " + pageNum);
|
|
Debug.Log(" Page " + pageNum);
|
|
|
|
|
|
if (allPage < 10)
|
|
if (allPage < 10)
|
|
@@ -102,7 +105,6 @@ public class PageBtnControl : MonoBehaviour
|
|
listPageItems[listPageItems.Count - 1].UpdatePage(allPage);
|
|
listPageItems[listPageItems.Count - 1].UpdatePage(allPage);
|
|
listPageItems[listPageItems.Count - 2].UpdateString(".....");
|
|
listPageItems[listPageItems.Count - 2].UpdateString(".....");
|
|
|
|
|
|
- NextBtn(false, true);
|
|
|
|
|
|
|
|
}
|
|
}
|
|
else if (allPage - pageNum < 6)
|
|
else if (allPage - pageNum < 6)
|
|
@@ -113,7 +115,6 @@ public class PageBtnControl : MonoBehaviour
|
|
}
|
|
}
|
|
listPageItems[0].UpdatePage(1);
|
|
listPageItems[0].UpdatePage(1);
|
|
listPageItems[1].UpdateString(".....");
|
|
listPageItems[1].UpdateString(".....");
|
|
- NextBtn(true, false);
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
@@ -145,11 +146,12 @@ public class PageBtnControl : MonoBehaviour
|
|
listPageItems[listPageItems.Count - 1].UpdatePage(allPage);
|
|
listPageItems[listPageItems.Count - 1].UpdatePage(allPage);
|
|
listPageItems[listPageItems.Count - 2].UpdateString(".....");
|
|
listPageItems[listPageItems.Count - 2].UpdateString(".....");
|
|
}
|
|
}
|
|
- NextBtn(false, false);
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
curretPage = pageNum;
|
|
curretPage = pageNum;
|
|
|
|
|
|
|
|
+ NextBtn();
|
|
|
|
+ onValueChanged.Invoke(curretPage);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i < listPageItems.Count; i++)
|
|
for (int i = 0; i < listPageItems.Count; i++)
|
|
@@ -161,11 +163,6 @@ public class PageBtnControl : MonoBehaviour
|
|
|
|
|
|
}
|
|
}
|
|
}
|
|
}
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
-
|
|
|
|
|
|
|
|
}
|
|
}
|
|
|
|
|
|
@@ -181,30 +178,14 @@ public class PageBtnControl : MonoBehaviour
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
- public void NextBtn( bool isrig1,bool isleft1 )
|
|
|
|
|
|
+ public void NextBtn( )
|
|
{
|
|
{
|
|
- if (isrig1)
|
|
|
|
- {
|
|
|
|
- rigNextBtn1.SetActive(true);
|
|
|
|
- rigNextBtn2.SetActive(false);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- rigNextBtn1.SetActive(false);
|
|
|
|
- rigNextBtn2.SetActive(true);
|
|
|
|
- }
|
|
|
|
-
|
|
|
|
|
|
+ Debug.Log("当�页"+curretPage+"总页数"+allPage);
|
|
|
|
+ leftNextBtn2.GetComponent<Button>().interactable=curretPage>1;
|
|
|
|
+ rigNextBtn2.GetComponent<Button>().interactable=allPage>curretPage;
|
|
|
|
+ // rigNextBtn2.GetComponent<Button>().interactable=!isrig1;
|
|
|
|
|
|
- if (isleft1)
|
|
|
|
- {
|
|
|
|
- leftNextBtn1.SetActive(true);
|
|
|
|
- leftNextBtn2.SetActive(false);
|
|
|
|
- }
|
|
|
|
- else
|
|
|
|
- {
|
|
|
|
- leftNextBtn1.SetActive(false);
|
|
|
|
- leftNextBtn2.SetActive(true);
|
|
|
|
- }
|
|
|
|
|
|
+ //
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
@@ -239,7 +220,7 @@ public class PageBtnControl : MonoBehaviour
|
|
// else
|
|
// else
|
|
// {
|
|
// {
|
|
|
|
|
|
-// if (itemNum <= 2) // µã»÷Ç°Á½¸ö²»ÐèÒª¸ÄÊý¾Ý
|
|
|
|
|
|
+// if (itemNum <= 2) // ���ǰ��������Ҫ������
|
|
// {
|
|
// {
|
|
// if (listPageItems[1].text.text == ".....")
|
|
// if (listPageItems[1].text.text == ".....")
|
|
// {
|
|
// {
|
|
@@ -306,7 +287,7 @@ public class PageBtnControl : MonoBehaviour
|
|
// {
|
|
// {
|
|
|
|
|
|
// {
|
|
// {
|
|
-// if (itemNum >= 4) // µã»÷Ç°Á½¸ö²»ÐèÒª¸ÄÊý¾Ý
|
|
|
|
|
|
+// if (itemNum >= 4) // ���ǰ��������Ҫ������
|
|
// {
|
|
// {
|
|
// if (listPageItems[1].text.text == ".....")
|
|
// if (listPageItems[1].text.text == ".....")
|
|
// {
|
|
// {
|