Tanoda
UndoDelete.cs
Go to the documentation of this file.
1using UnityEngine;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5using GILES.Interface;
6
7namespace GILES
8{
14 public class UndoDelete : IUndo
15 {
16 public IEnumerable<GameObject> gameObjects;
17
18 public UndoDelete(IEnumerable<GameObject> selection)
19 {
20 this.gameObjects = selection;
21 }
22
23 public Hashtable RecordState()
24 {
25 Hashtable hash = new Hashtable();
26
27 int n = 0;
28 var delgo = new GameObject("DeletedItems");
29 delgo.SetActive(false);
30 foreach(GameObject go in gameObjects)
31 {
32 //go.SetActive(false);
33 hash.Add(n++, go);
34 hash.Add(n++, go.transform.parent);
35 go.transform.SetParent(delgo.transform, true);
36 pb_Hierarchy.instance.RebuildInspector();
37 }
38 HttpCookie.SetCookie("unsavedChanges", "true", "", "/", "", "");
39
40 return hash;
41 }
42
43 public void ApplyState(Hashtable hash)
44 {
45 for (int i = 0; i < hash.Count; i += 2)
46 {
47 var go = hash[i] as GameObject;
48 var parent = hash[(i + 1)] as Transform;
49 go.transform.SetParent(parent, true);
50 pb_Hierarchy.instance.RebuildInspector();
51 }
52 }
53
54 public void OnExitScope()
55 {
56 foreach(GameObject go in gameObjects)
57 {
58 if (go != null && !go.activeSelf)
59 pb_ObjectUtility.Destroy(go);
60 }
61 }
62 }
63}
Hashtable RecordState()
Definition: UndoDelete.cs:23
UndoDelete(IEnumerable< GameObject > selection)
Definition: UndoDelete.cs:18
void OnExitScope()
Definition: UndoDelete.cs:54
IEnumerable< GameObject > gameObjects
Definition: UndoDelete.cs:16
void ApplyState(Hashtable hash)
Definition: UndoDelete.cs:43