PageItem.cs 1.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455
  1. using System.Collections;
  2. using System.Collections.Generic;
  3. using UnityEngine;
  4. using UnityEngine.UI;
  5. public class PageItem : MonoBehaviour
  6. {
  7. public int page;
  8. public Text text;
  9. public PageBtnControl pageBtnControl;
  10. public int itemNum;
  11. public Image image;
  12. private void Start()
  13. {
  14. pageBtnControl = transform.parent.gameObject.GetComponent<PageBtnControl>();
  15. image = transform.GetComponent<Image>();
  16. transform.GetComponent<Button>().onClick.AddListener(OnClick);
  17. page = itemNum;
  18. }
  19. public void UpdatePage( int Page)
  20. {
  21. this.page = Page;
  22. text.text = page.ToString();
  23. image.color = Color.white;
  24. }
  25. public void UpdateString( string str)
  26. {
  27. text.text = str;
  28. image.color = Color.white;
  29. this.page = -1;
  30. }
  31. public void OnClick()
  32. {
  33. if(text.text !=page.ToString())
  34. {
  35. pageBtnControl.UpdateMiddleData(itemNum);
  36. }
  37. else
  38. {
  39. pageBtnControl.updateData(itemNum, page);
  40. }
  41. }
  42. public void ShowUI()
  43. {
  44. image.color = Color.blue;
  45. }
  46. }