Tanoda
ResourceDeleter.cs
Go to the documentation of this file.
1using System.Collections;
2using System.Collections.Generic;
3using GILES.Interface;
4using NaughtyAttributes;
5using UnityEngine;
6
7public class ResourceDeleter : MonoBehaviour
8{
9 [Button]
10 public void Delete()
11 {
12 YesNoPopupManager.instance.ShowPopup(Macro.T("CONFIRM_DIALOG"), Macro.T("CONFIRM_DELETE"));
13 YesNoPopupManager.instance.InvokeOnYes(ActualDelete);
14 }
15
16 private void ActualDelete()
17 {
18#if !UNITY_WEBGL
19 var pbib = GetComponentInParent<pb_PrefabBrowserItemButton>();
20 if (pbib.fullFilePath != "")
21 {
22 var tc = pbib.asset.GetComponent<TagCloud>();
23 if (tc)
24 {
25 var alltc = FindObjectsOfType<TagCloud>(true);
26 foreach (var tag in alltc)
27 {
28 if (tag.filePath == tc.filePath)
29 {
30 Destroy(tag.gameObject);
31 }
32 }
33 }
34 System.IO.File.Delete(pbib.fullFilePath);
36 Destroy(pbib.asset);
37 Destroy(transform.parent.gameObject);
39 }
40#else
41 var pbib = GetComponentInParent<pb_PrefabBrowserItemButton>();
42 UploadLevelObjects.instance.QueueDelete(pbib.fullFilePath);
43 var tc = pbib.asset.GetComponent<TagCloud>();
44 if (tc)
45 {
46 var alltc = FindObjectsOfType<TagCloud>(true);
47 foreach (var tag in alltc)
48 {
49 if (tag.filePath == tc.filePath)
50 {
51 Destroy(tag.gameObject);
52 }
53 }
54 }
56 Destroy(pbib.asset);
57 Destroy(transform.parent.gameObject);
59#endif
60 }
61}
UnityEngine.UI.Button Button
Definition: Pointer.cs:7
void Reload(bool global=false)
static pb_PrefabBrowser instance
void DeleteAsset(GameObject asset)
Definition: Macro.cs:12
static string T(string key)
Definition: Macro.cs:19
static UploadLevelObjects instance
void QueueDelete(string fileName)