using System; using System.Collections.Generic; using LitJson; using SC.XR.Unity; using TMPro; using UnityEngine; using UnityEngine.UI; using static WindowsManager; public class RoomFile : SingletonMono { public Toggle fileToggle; public GameObject tubiao1; public GameObject tubiao2; public GameObject allFile; public Button clearAllBtn; public GameObject msgRemind; public TextMeshProUGUI msgRemindText; public TextMeshProUGUI showfileCountText; public static int fileUpdataCount = 0; public Action UpdataCountAction; public static Action ClickFileItemAction; public List FilePrefabConfigList = new List();//是否实例化的List public static Action IfFilePrefabConfigListAction;//点击知道是否实例化的监听 public static Action ClickOnPrefabAction; public static Action HideChooseKuangAction; public static Action HidefileChooseAction; public static Action SetIsOnFalse; public Transform PngJpgPoint; public Transform PrintscreenPoint; public Transform Mp4Point; public Transform PdfPoint; public Transform ModelPoint; void Awake() { UpdataCountAction += OnUpdataCount; // MQTTClient.Instance.OnCoordinate += Coordinate; } private void ReceiveSharePrintscreen(JsonData data) { if (PrintscreenList.Instance) { PrintscreenList.Instance.AddItem(data); } } private void OnUpdataCount(int num) { msgRemind.SetActive(true); msgRemindText.text = num.ToString(); } private void Start() { ClickFileItemAction += ClickFileItme; fileToggle.onValueChanged.AddListener(OnFileToggleValueChange); clearAllBtn.onClick.AddListener(ClickOnClearAllBtn); ClearAllfileAction += ClearAllfile; } private void ReceiveFile(JsonData data) { FileConfig fileConfig = new FileConfig(); fileConfig.PeerId = data["data"]["peerId"].ToString(); fileConfig.From = data["data"]["from"].ToString(); fileConfig.CreateTime = data["data"]["createTime"].ToString(); fileConfig.Url = data["data"]["url"].ToString(); fileConfig.Path = data["data"]["path"].ToString(); fileConfig.FileName = data["data"]["fileName"].ToString(); InstantFileConfig(fileConfig); } private void InstantFileConfig(FileConfig fileConfig) { if (FileList.Instance) { FileList.Instance.AddItem(fileConfig); } } void initShow() { HideClearBtn(); if (FileList.Instance) { fileUpdataCount = 0; // FileList.Instance.Init(ShowRoom.Instance.fileConfiglist); } if (fileToggle) { fileToggle.isOn = true; } allFile.SetActive(true); tubiao1.SetActive(false); tubiao2.SetActive(true); msgRemind.SetActive(false); fileUpdataCount = 0; } public void ShowClearBtn() { clearAllBtn.gameObject.SetActive(true); //showfileCountText.transform.localPosition = new Vector3(15, 0, 0); } public void HideClearBtn() { clearAllBtn.gameObject.SetActive(false); //showfileCountText.transform.localPosition = new Vector3(-3, 0, 0); } private void OnFileToggleValueChange(bool isOn) { if (isOn) { allFile.SetActive(true); tubiao1.SetActive(false); tubiao2.SetActive(true); msgRemind.SetActive(false); fileUpdataCount = 0; } else { allFile.SetActive(false); tubiao1.SetActive(true); tubiao2.SetActive(false); } } public void ResetToggleValue() { if (!fileToggle.isOn) { fileToggle.isOn = true; } } private Action ClearAllfileAction; private void ClickOnClearAllBtn() { // PopUpInfo.Instance.showPublic(PopUpInfo.PopType.Pop, RtcStrConfig.clearallFile, "确定", ClearAllfileAction); } private void ClearAllfile() { HideClearBtn(); } private void ClearFileSucess(JsonData data) { if (data["data"]["code"].ToString() == "200") { ClearAllFileItem(); } } private void ClearFile(JsonData data) { if (data["method"].ToString() == "clearFile") { ClearAllFileItem(); } } public void ClearAllFileItem() { //if (ShowRoom.Instance && ShowRoom.Instance.fileConfiglist != null && ShowRoom.Instance.fileConfiglist.Count > 0) //{ // ShowRoom.Instance.fileConfiglist.Clear(); //} if (FileList.Instance) { msgRemind.SetActive(false); fileUpdataCount = 0; FileList.Instance.DestoryAll(); } ClearAllFilePrefab(); } public void ClearAllFilePrefab() { if (PngJpgList.Instance) { PngJpgList.Instance.DeleteAll(); } if (Mp4List.Instance) { Mp4List.Instance.DeleteAll(); } if (PdfList.Instance) { PdfList.Instance.DeleteAll(); } //if (ModelList.Instance) //{ // ModelList.Instance.DeleteAll(); //} FilePrefabConfigList.Clear(); } private void ClickFileItme(FileConfig fileConfig) { if (fileConfig != null) { switch (fileConfig.FileType) { case RoomFileType.png: if (PngJpgList.Instance) { PngJpgList.Instance.AddItem(fileConfig); } break; case RoomFileType.jpg: if (PngJpgList.Instance) { PngJpgList.Instance.AddItem(fileConfig); } break; case RoomFileType.jpeg: if (PngJpgList.Instance) { PngJpgList.Instance.AddItem(fileConfig); } break; case RoomFileType.mp4: if (Mp4List.Instance) { Mp4List.Instance.AddItem(fileConfig); } break; case RoomFileType.zip: //if (ModelList.Instance) //{ // ModelList.Instance.AddItem(fileConfig); //} break; case RoomFileType.pdf: if (PdfList.Instance) { PdfList.Instance.AddItem(fileConfig); } break; } } } private void OnDestroy() { ClickFileItemAction -= ClickFileItme; UpdataCountAction -= OnUpdataCount; ClearAllfileAction -= ClearAllfile; } }