123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384 |
- using System;
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using UnityEngine.UI;
- public class TaskListPanel : MonoBehaviour
- {
- public Button taskTpye_allButton;
- public Button taskTpye_dianQiButton;
- public Button taskTpye_zhaZhanButton;
- public Button taskTpye_diFangButton;
- public Button taskTpye_jianZhuButton;
- public Button taskTpye_zhuanXiangButton;
- public InputField inputField;
-
- public GameObject taskItemPrefab;
- public Transform itemContent;
- public List<B08_TaskListItem> taskItemList = new List<B08_TaskListItem>();
- public GCYWLayer gcywLayer;
- public B08_TaskListData[] taskInfoList;
-
- private void Awake()
- {
- taskTpye_allButton.onClick.AddListener(()=>SetType("-1"));
- taskTpye_dianQiButton.onClick.AddListener(()=>SetType("0"));
- taskTpye_zhaZhanButton.onClick.AddListener(()=>SetType("1"));
- taskTpye_diFangButton.onClick.AddListener(()=>SetType("2"));
- taskTpye_jianZhuButton.onClick.AddListener(()=>SetType("3"));
- taskTpye_zhuanXiangButton.onClick.AddListener(()=>SetType("4"));
-
- inputField.onValueChanged.AddListener(Search);
- }
- public void Search(string inputStr)
- {
- for (int i = 0; i < taskItemList.Count; i++)
- {
- taskItemList[i].gameObject.SetActive(taskItemList[i].InfoData.title.Contains(inputStr));
- }
- }
-
- public void SetType(string type)
- {
- if (type.Equals("-1"))
- {
- for (int i = 0; i < taskItemList.Count; i++)
- {
- taskItemList[i].gameObject.SetActive(true);
- }
- return;
- }
- for (int i = 0; i < taskItemList.Count; i++)
- {
- taskItemList[i].gameObject.SetActive(taskItemList[i].InfoData.type.Equals(type));
- }
- }
- public void SetData(GCYWLayer baseLayer)
- {
- gcywLayer = baseLayer;
- for (int i = 0; i < taskItemList.Count; i++)
- {
- Destroy(taskItemList[i].gameObject);
- }
- taskItemList.Clear();
- taskInfoList = GlobalData.B08TaskListData.rows;
- if (taskInfoList != null)
- {
- for (int j = 0; j < taskInfoList.Length; j++)
- {
- B08_TaskListItem tempItem = Instantiate(taskItemPrefab, itemContent).GetComponent<B08_TaskListItem>();
- tempItem.Init();
- tempItem.SetData(gcywLayer, taskInfoList[j].infoData);
- taskItemList.Add(tempItem);
- }
- }
- }
- }
|