TaskPhotoPanel.cs 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  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. public Text dateText;
  17. public string _timeInfo;
  18. private void Awake()
  19. {
  20. lastItem.onClick.AddListener(Last);
  21. nextItem.onClick.AddListener(Next);
  22. }
  23. public void SetData(B08_TaskItems[] items,string _time)
  24. {
  25. currentIndex = 0;
  26. task_items = items;
  27. _timeInfo = _time;
  28. ChangePage(currentIndex);
  29. }
  30. public void Next()
  31. {
  32. if (currentIndex < task_items.Length - 1)
  33. {
  34. currentIndex++;
  35. ChangePage(currentIndex);
  36. }
  37. }
  38. public void Last()
  39. {
  40. if (currentIndex > 0)
  41. {
  42. currentIndex--;
  43. ChangePage(currentIndex);
  44. }
  45. }
  46. public void ChangePage(int pageIndex)
  47. {
  48. var currentData = task_items[pageIndex];
  49. string path ="http://58.19.230.46:9180/prod-api/uploads/"+currentData.files[0].filePath;
  50. TextureLoadHelp._Instance.LoadTexFromUrl(path, img);
  51. Debug.Log(currentData.faItemName+" "+currentData.startTime+" "+currentData.finishedTime);
  52. posText.text = currentData.faItemName;
  53. messageText.text = currentData.faItemName;
  54. pageText.text = $"{pageIndex + 1}/{task_items.Length}";
  55. dateText.text = _timeInfo;
  56. }
  57. }