任务显示修复

This commit is contained in:
huyulong 2024-12-06 11:52:15 +08:00
parent 3dd80a3816
commit a8dbfec82d

View File

@ -4,6 +4,7 @@ using System.Collections.Generic;
using UnityEngine;
using UnityEngine.UI;
using DG.Tweening;
using System.Threading.Tasks;
public class TaskPanel : Base
{
@ -33,8 +34,9 @@ public class TaskPanel : Base
}
public void InitTask()
public async void InitTask()
{
await DestroyTaskAsync();
for(int i = 0; i < taskId.Count;i++)
{
GameObject go = GameObject.Instantiate(taskPrefab, contentTrans);
@ -44,9 +46,24 @@ public class TaskPanel : Base
}
}
public async Task DestroyTaskAsync()
{
DeleteAllChildObjects();
await Task.Delay(10);
}
public void DeleteAllChildObjects()
{
// 遍历所有子物体并删除
foreach (Transform child in contentTrans)
{
Destroy(child.gameObject);
}
}
public void SetInfo(int id)
{
taskId.Add(id);
InitTask();
}