using System.Collections; using System.Collections.Generic; using UnityEngine; using XRTool.Util; public class FileList : UnitySingleton { public GameObject Item; public void Init(List fileConfiglist) { if (transform.childCount > 0) { for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } } for (int i = 0; i < fileConfiglist.Count; i++) { AddItem(fileConfiglist[i]); } fileConfiglist.Clear(); } public void AddItem(FileConfig fileConfig) { if (!RoomFile.Instance.allFile.activeSelf) { RoomFile.fileUpdataCount++; RoomFile.Instance.UpdataCountAction?.Invoke(RoomFile.fileUpdataCount); } GameObject obj = Instantiate(Item, transform) as GameObject; obj.transform.GetComponent().Init(fileConfig); if (RoomMainInfo.isCreator == "0") { RoomFile.Instance.ShowClearBtn(); } if (RoomInfo.Instance && fileConfig != null) { RoomInfo.Instance.ctManager.SetText(fileConfig.From + "发送了文件:" + fileConfig.FileName); } RoomFile.Instance.showfileCountText.text = "文件-" + transform.childCount.ToString(); } public void RemoveItem(FileConfig fileConfig) { if (this.transform.childCount == 1 && RoomMainInfo.isCreator == "0") { RoomFile.Instance.HideClearBtn(); } if (RoomInfo.Instance && fileConfig != null) { //RoomInfo.Instance.ctManager.SetText(fileConfig.From + "删除了文件:" + fileConfig.FileName); } if (this.transform.childCount >= 1) { RoomFile.Instance.showfileCountText.text = "文件-" + (transform.childCount - 1).ToString(); } } public void DestoryAll() { if (transform.childCount > 0) { for (int i = 0; i < transform.childCount; i++) { Destroy(transform.GetChild(i).gameObject); } } RoomFile.Instance.showfileCountText.text = "文件-" + 0; } }