void Awake() { if (instance) { Destroy(this.gameObject); } else { instance = this; } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
private void Awake() { audioSource = GetComponent <AudioSource>(); Instance = null; if (Instance == null) { Instance = this; } else if (Instance != null) { Destroy(this); } DontDestroyOnLoad(this); }
private void Start() { // Get references uIController = uIControllerContainer.GetComponent <UI>(); startDialogAnimator = startDialogContainer.GetComponent <Animator>(); playerController = playerContainer.GetComponent <Player>(); diamondsController = diamondsContainer.GetComponent <DiamondsController>(); transitionController = transitionContainer.GetComponent <SceneTransition>(); bgSoundManager = GameObject.FindGameObjectWithTag(Utilities.BG_SOUND_MANAGER_TAG).GetComponent <BgSound>(); effSoundManager = GameObject.FindGameObjectWithTag(Utilities.EFF_SOUND_MANAGER_TAG).GetComponent <SoundEffect>(); if (movingEnemiesContainer != null) { movingEnemiesController = movingEnemiesContainer.GetComponent <MovingEnemies>(); } lvlReached = PlayerPrefs.GetInt(Utilities.LVL_REACHED_TAG, 1); totalRecordedScore = PlayerPrefs.GetInt(Utilities.TOTAL_SCORE_TAG, 0); totalRecordedCoins = PlayerPrefs.GetInt(Utilities.TOTAL_COINS_TAG, 0); totalRecordedTime = PlayerPrefs.GetFloat(Utilities.TOTAL_TIME_TAG, 0f); totalRecordedDeaths = PlayerPrefs.GetInt(Utilities.TOTAL_DEATHS_TAG, 0); // Init coins value totalCoinsCount = diamondsController.TotalCoinsCount(); uIController.SetCoinsCount(totalCoinsCount); uIController.SetMaxBoostTime(this.maxBoostTime); // Setup environment Reset(); PauseGame(true); // Show pop up UI StartCoroutine(ShowStartDialog()); }