123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102 |
- using System.Collections;
- using System.Collections.Generic;
- using UnityEngine;
- using XRTool.Util;
- public class FileList : UnitySingleton<FileList>
- {
- public GameObject Item;
- public GameObject MesItem;
- public RectTransform FileContent;
- 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);
- }
-
-
- 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();
- GameObject MsgItem = GameObject.Instantiate(MesItem, transform) as GameObject;
- MsgItem.GetComponent<MsgItem>().Init(null, fileConfig);
- if (FileContent == null)
- FileContent = transform.GetComponent<RectTransform>();
- else
- FileContent.anchoredPosition3D += new Vector3(0, 100, 0);
- }
- public void AddMsgItem(Sprite head, string name , string msg)
- {
- GameObject MsgItem = GameObject.Instantiate(MesItem, transform) as GameObject;
- MsgItem.GetComponent<MsgItem>().Init(null, name, msg);
- if (FileContent == null)
- FileContent = transform.GetComponent<RectTransform>();
- else
- FileContent.anchoredPosition3D += new Vector3(0, 100, 0);
- }
- public void RemoveItem(FileConfig fileConfig)
- {
- if (this.transform.childCount == 1 && RoomMainInfo.isCreator == "0")
- {
- RoomFile.Instance.HideClearBtn();
- }
- if (RoomInfo.Instance && fileConfig != null)
- {
-
- }
- 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;
- }
- }
|