void Start() { isUnderwater = false; saveManagerScript = GameObject.FindWithTag("SaveManager").GetComponent <SaveManagerScript>(); rectTransform = gameObject.GetComponent <RectTransform>(); StartCoroutine(DepleteAir()); }
private void Awake() { saveManagerScript = GameObject.FindWithTag("SaveManager").GetComponent <SaveManagerScript>(); StartController.OnCloseStartCanvas += JumpInWater; ShopController.OnCloseShop += JumpInWater; ShopController.OnBuySpeed += AddSpeed; ShopController.OnBuyFlashlight += AddFlashLight; }
//Awake is always called before any Start functions void Awake() { //Check if instance already exists if (instance == null) { //if not, set instance to this instance = this; } //If instance already exists and it's not this: else if (instance != this) { //Then destroy this. This enforces our singleton pattern, meaning there can only ever be one instance of a GameManager. Destroy(gameObject); } //Sets this to not be destroyed when reloading scene DontDestroyOnLoad(gameObject); }
public void OnSceneLoaded(Scene scene, LoadSceneMode mode) { Scene currentScene = SceneManager.GetActiveScene(); if (currentScene.name == "Game") { saveManagerScript = GameObject.FindWithTag("SaveManager").GetComponent <SaveManagerScript>(); if (isLoadingGame) { LoadData(); saveManagerScript.LoadFields(loadData); } } else if (currentScene.name == "GameEndScene") { isLoadingGame = false; File.Delete(Application.persistentDataPath + "/SaveData.json"); } }