using UnityEngine;
using System.Collections;
public class SaveObject : MonoBehaviour {
private GameObject saveObj;
public bool isSave = false;
public bool isLoad = false;
void Start () {
isSave = true;
}
void Update () {
if (isSave) {
isSave = false;
if (saveObj) {
Destroy(saveObj);
}
saveObj = (GameObject)Instantiate(gameObject);
saveObj.name = name;
saveObj.hideFlags = HideFlags.HideInHierarchy;
saveObj.SetActiveRecursively(false);
}
if (isLoad) {
isLoad = false;
if (saveObj) {
saveObj.SetActiveRecursively(true);
saveObj.hideFlags = 0;
Destroy(gameObject);
}
}
}
}
dXNpbmcgVW5pdHlFbmdpbmU7CnVzaW5nIFN5c3RlbS5Db2xsZWN0aW9uczsKCnB1YmxpYyBjbGFzcyBTYXZlT2JqZWN0IDogTW9ub0JlaGF2aW91ciB7Cglwcml2YXRlIEdhbWVPYmplY3Qgc2F2ZU9iajsKCXB1YmxpYyBib29sIGlzU2F2ZSA9IGZhbHNlOwoJcHVibGljIGJvb2wgaXNMb2FkID0gZmFsc2U7Cgl2b2lkIFN0YXJ0ICgpIHsKCQlpc1NhdmUgPSB0cnVlOwoJfQoJdm9pZCBVcGRhdGUgKCkgewoJCWlmIChpc1NhdmUpIHsKCQkJaXNTYXZlID0gZmFsc2U7CgkJCWlmIChzYXZlT2JqKSB7CgkJCQlEZXN0cm95KHNhdmVPYmopOwoJCQl9CgkJCXNhdmVPYmogPSAoR2FtZU9iamVjdClJbnN0YW50aWF0ZShnYW1lT2JqZWN0KTsKCQkJc2F2ZU9iai5uYW1lID0gbmFtZTsKCQkJc2F2ZU9iai5oaWRlRmxhZ3MgPSBIaWRlRmxhZ3MuSGlkZUluSGllcmFyY2h5OwoJCQlzYXZlT2JqLlNldEFjdGl2ZVJlY3Vyc2l2ZWx5KGZhbHNlKTsKCQl9CgkJaWYgKGlzTG9hZCkgewoJCQlpc0xvYWQgPSBmYWxzZTsKCQkJaWYgKHNhdmVPYmopIHsKCQkJCXNhdmVPYmouU2V0QWN0aXZlUmVjdXJzaXZlbHkodHJ1ZSk7CgkJCQlzYXZlT2JqLmhpZGVGbGFncyA9IDA7CgkJCQlEZXN0cm95KGdhbWVPYmplY3QpOwoJCQl9CgkJfQoJfQp9