fork download
  1. using UnityEngine;
  2. using System.Collections;
  3.  
  4. public class SaveObject : MonoBehaviour {
  5. private GameObject saveObj;
  6. public bool isSave = false;
  7. public bool isLoad = false;
  8. void Start () {
  9. isSave = true;
  10. }
  11. void Update () {
  12. if (isSave) {
  13. isSave = false;
  14. if (saveObj) {
  15. Destroy(saveObj);
  16. }
  17. saveObj = (GameObject)Instantiate(gameObject);
  18. saveObj.name = name;
  19. saveObj.hideFlags = HideFlags.HideInHierarchy;
  20. saveObj.SetActiveRecursively(false);
  21. }
  22. if (isLoad) {
  23. isLoad = false;
  24. if (saveObj) {
  25. saveObj.SetActiveRecursively(true);
  26. saveObj.hideFlags = 0;
  27. Destroy(gameObject);
  28. }
  29. }
  30. }
  31. }
Not running #stdin #stdout 0s 0KB
stdin
Standard input is empty
stdout
Standard output is empty