Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- using System.Collections;
- using UnityEngine;
- public class AutoSaving : MonoBehaviour
- {
- public float savingPeriod = 60f;
- private World world;
- void Start ()
- {
- world = World.GetInstance ();
- StartCoroutine (OnSaveData ());
- }
- IEnumerator OnSaveData ()
- {
- while (true) {
- yield return new WaitForSecondsRealtime (savingPeriod);
- Save ();
- }
- }
- public void Save ()
- {
- Debug.Log ("Saving...");
- DataManager.SaveData (world);
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment