Tanoda
UndoInstantiate.cs
Go to the documentation of this file.
1using UnityEngine;
2using System.Collections;
3using System.Collections.Generic;
4using System.Linq;
5
6namespace GILES
7{
11 public class UndoInstantiate : IUndo
12 {
13 public GameObject gameObject;
14 [SerializeField] bool initialized = false;
15
16 public UndoInstantiate(GameObject go)
17 {
18 this.gameObject = go;
19 initialized = false;
20 }
21
22 public Hashtable RecordState()
23 {
24 Hashtable hash = new Hashtable();
25 hash.Add(gameObject, initialized ? gameObject.activeSelf : false);
26 initialized = true;
27 HttpCookie.SetCookie("unsavedChanges", "true", "", "/", "", "");
28 return hash;
29 }
30
31 public void ApplyState(Hashtable hash)
32 {
33 foreach(DictionaryEntry kvp in hash)
34 ((GameObject)kvp.Key).SetActive((bool)kvp.Value);
35 }
36
37 public void OnExitScope()
38 {
39 if( gameObject != null && !gameObject.activeSelf )
40 pb_ObjectUtility.Destroy(gameObject);
41 }
42 }
43}
void ApplyState(Hashtable hash)
UndoInstantiate(GameObject go)