TaskPhotoPanel.cs 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. using System;
  2. using System.Collections;
  3. using System.Collections.Generic;
  4. using UnityEngine;
  5. using UnityEngine.UI;
  6. public class TaskPhotoPanel : MonoBehaviour
  7. {
  8. public RawImage img;
  9. public Text posText;
  10. public Text messageText;
  11. public Text pageText;
  12. public Button lastItem;
  13. public Button nextItem;
  14. public B08_TaskItems[] task_items;
  15. public int currentIndex = 0;
  16. private void Awake()
  17. {
  18. lastItem.onClick.AddListener(Last);
  19. nextItem.onClick.AddListener(Next);
  20. }
  21. public void SetData(B08_TaskItems[] items)
  22. {
  23. currentIndex = 0;
  24. task_items = items;
  25. ChangePage(currentIndex);
  26. }
  27. public void Next()
  28. {
  29. if (currentIndex < task_items.Length - 1)
  30. {
  31. currentIndex++;
  32. ChangePage(currentIndex);
  33. }
  34. }
  35. public void Last()
  36. {
  37. if (currentIndex > 0)
  38. {
  39. currentIndex--;
  40. ChangePage(currentIndex);
  41. }
  42. }
  43. public void ChangePage(int pageIndex)
  44. {
  45. var currentData = task_items[pageIndex];
  46. TextureLoadHelp._Instance.LoadTexFromUrl(currentData.img_path,img);
  47. posText.text = currentData.item_name;
  48. messageText.text = currentData.item_name;
  49. pageText.text = $"{pageIndex + 1}/{task_items.Length}";
  50. }
  51. }