12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- public class FileList : UnitySingleton<FileList>
- {
- public GameObject Item;
- public void Init(List<FileConfig> 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<FileItem>().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;
- }
- }
|