_xiaofang/xiaofang/Assets/Res/HYLUI/TaskPanel.cs

84 lines
1.4 KiB
C#
Raw Normal View History

using System;
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
public class TaskPanel : Base
{
public static TaskPanel instance;
2024-12-05 20:21:15 +08:00
public List<int> taskId = new List<int>();
public Transform contentTrans;
public GameObject taskPrefab;
public JSONReader JSONReader;
public Dictionary<int, Language> taskDic = new Dictionary<int, Language>();
public Button closeBtn;
private bool isOpen = false;
// Start is called before the first frame update
void Start()
{
instance = this;
closeBtn.onClick.AddListener(CloseBtn);
2024-12-05 20:21:15 +08:00
2024-12-05 20:21:15 +08:00
}
public void InitTask()
{
for(int i = 0; i < taskId.Count;i++)
{
GameObject go = GameObject.Instantiate(taskPrefab, contentTrans);
go.transform.name = "Task_" + i;
TaskItem item = go.GetComponent<TaskItem>();
item.SetInfo(taskId[i], JSONReader);
2024-12-05 20:21:15 +08:00
}
}
2024-12-05 20:21:15 +08:00
public void SetInfo(int id)
{
taskId.Add(id);
InitTask();
}
public void CloseBtn()
{
if (isOpen)//<2F>ر<EFBFBD><D8B1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
isOpen = false;
}
else//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
{
isOpen = true;
}
}
2024-12-05 20:21:15 +08:00
// Update is called once per frame
void Update()
{
if(Input.GetKeyDown(KeyCode.J))
{
SetInfo(11001);
}
}
}