12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TaskPhotoPanel : MonoBehaviour
- {
- public RawImage img;
- public Text posText;
- public Text messageText;
- public Text pageText;
- public Button lastItem;
- public Button nextItem;
-
- public B08_TaskItems[] task_items;
- public int currentIndex = 0;
- private void Awake()
- {
- lastItem.onClick.AddListener(Last);
- nextItem.onClick.AddListener(Next);
- }
- public void SetData(B08_TaskItems[] items)
- {
- currentIndex = 0;
- task_items = items;
- ChangePage(currentIndex);
- }
- public void Next()
- {
- if (currentIndex < task_items.Length - 1)
- {
- currentIndex++;
- ChangePage(currentIndex);
- }
- }
- public void Last()
- {
- if (currentIndex > 0)
- {
- currentIndex--;
- ChangePage(currentIndex);
- }
- }
- public void ChangePage(int pageIndex)
- {
- var currentData = task_items[pageIndex];
- TextureLoadHelp._Instance.LoadTexFromUrl(currentData.img_path,img);
- posText.text = currentData.item_name;
- messageText.text = currentData.item_name;
- pageText.text = $"{pageIndex + 1}/{task_items.Length}";
- }
- }
|