public void ClearRes() { ResMap.Clear(); var lst = new List <Transform>(); foreach (Transform child in Content) { lst.Add(child); } for (int i = 0; i < lst.Count; i++) { Destroy(lst[i].gameObject); } DirTools.CleanUpDir(); }
protected override void OnInit(QFramework.IUIData uiData) { mData = uiData as UIResourcePanelData ?? new UIResourcePanelData(); // please add init code here var activity = mData.activityIndex; var id = mData.id; TextLabel.text = "ResArea-" + activity; var version = PlayerPrefs.GetString("Version"); gameObject.AddComponent <FileDragAndDrop>(); DirTools.ActivityIndex = activity; DirTools.Version = version; TypeEventSystem.Register <ResBlockNameChanged>(NameChanged); Export.onClick.AddListener(ExportRes); Clear.onClick.AddListener(ClearRes); God.onClick.AddListener(() => { UIMgr.OpenPanel("UIUploadPanel", UILevel.Common, new UIUploadPanelData() { ActivityIndex = activity, id = id }); }); TypeEventSystem.Register <RemoveBlock>((tmp) => { var md5 = tmp.MD5; ResMap.Remove(md5); string resDir = DirTools.GetTmpResDir(); string filepath = Path.Combine(resDir, md5 + tmp.Extension); if (File.Exists(filepath)) { File.Delete(filepath); } else { Debug.LogError("资源不存在!!!"); } }); TypeEventSystem.Register <SetBlockProperties>((tmp) => { var md5 = tmp.MD5; var properties = tmp.properties; var ResBlock = ResMap[md5]; ResBlock.GetComponent <ResBlockScript>().Properties = properties; }); TypeEventSystem.Register <ClearRescoursePanel>((tmp) => { ResMap.Clear(); var lst = new List <Transform>(); foreach (Transform child in Content) { lst.Add(child); } for (int i = 0; i < lst.Count; i++) { Destroy(lst[i].gameObject); } DirTools.DeleteFolder(DirTools.GetTmpResDir()); }); TypeEventSystem.Register <FilePathInfo>((file) => { if (ResMap.ContainsKey(file.MD5)) { return; } else if (file.Extension == ".zip") { MessageBoxV2.AddMessage("暂不支持拖入zip", 3); } else { var BlockImage = Instantiate(ResBlockPrefab, Content); BlockImage.GetComponent <ResBlockScript>().SetImage(file); DirTools.CopyDropFileToTmpResDir(file); ResMap.Add(file.MD5, BlockImage); } }); DirTools.CleanUpDir(); ResMap.Clear(); #if UNITY_EDITOR Invoke("Test", 3.0f); #endif }