TaskPhotoPanel.cs 1.4 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859
  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. string path = currentData.img_path.Replace("10.123.10.11", "58.19.230.46");
  47. TextureLoadHelp._Instance.LoadTexFromUrl(path, img);
  48. posText.text = currentData.item_name;
  49. messageText.text = currentData.item_name;
  50. pageText.text = $"{pageIndex + 1}/{task_items.Length}";
  51. }
  52. }