Ejemplo n.º 1
0
    void Awake()
    {
        //DontDestroyOnLoad make the object available even when you change the scene.
        //The problem is that you must enter a scene that have the object first
        //The solution is to have one copy of the object on each scene, but when you change scenes
        //the object from previous scene is there too. So you make sure you Destroy this if there is another
        //object from the class instanced.
        //It can be verified because the variable "control" is static and is unique for every object on the class.
        //So you can verify if any object of the class is in the control static variable.
        if (control == null)
        {
            DontDestroyOnLoad(gameObject);
            control = this;
            control.Load();
        }
        else if (control != this)
        {
            Destroy(gameObject);
        }

        //#if !UNITY_WP8

        /*
         * completeFilePath = Application.persistentDataPath + "/"+fileName;
         */
        //#endif
    }
Ejemplo n.º 2
0
    void Start()
    {
        PersistenceKey = transform.position;

        _controller = GameObject.FindGameObjectWithTag(Tag.GameController)
                      .GetComponent <PersistenceController>();

        if (_controller.HasSavedData(this))
        {
            if ((ResetsOnGameStart &&
                 _controller.HasBeenLoaded.ContainsKey(this.PersistenceKey)) ||
                !ResetsOnGameStart)
            {
                _controller.Load(this);
            }
            else
            {
                _controller.NotifyLoad(this);
            }
        }

        gameObject.SetActive(Enabled);

        _isInitialized = true;
    }
Ejemplo n.º 3
0
 public void DebugLoad()
 {
     PersistenceController.Load();
 }