void Awake() { if (instance != null) { Destroy(this); return; } instance = this; }
void Start() { currentStage = 1; stg2ButtonActivations = 0; nextTrapSetTimer = Time.time + trapCooldown - 1f; playerTransform = GameObject.FindGameObjectWithTag("Player").transform; musicManager = FindObjectOfType <MusicManagerScript>(); musicManager.StartStage1Music(); }
void OnDestroy() { //If you destroy the singleton elsewhere, reset the instance to null, //but don't reset it every time you destroy any instance of MusicManagerScript //because then the singleton pattern won't work (because the Singleton code in //Awake destroys it too) if (instance == this) { instance = null; } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
private void Awake() { audioSource = GetComponent<AudioSource>(); if (Instance != null && Instance != this) { Destroy(gameObject); return; } else { Instance = this; } DontDestroyOnLoad(gameObject); audioSource.clip = MusicClip; audioSource.Play(); }
private void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); audioSound = GetComponent <AudioSource>(); }
void MovePlayer() { if (player == null) { return; } if (Music != BGM.NULL) { MusicManagerScript bgm = GameObject.FindObjectOfType <MusicManagerScript>(); bgm.Play(Music); } Vector3 pos = player.position; pos.x = target.x; pos.y = target.y; player.position = pos; }
void Start() { musicManager = GameObject.FindObjectOfType <MusicManagerScript>(); volumeSlider.value = PlayerPrefsManager.GetMasterVolume(); difficultySlider.value = PlayerPrefsManager.GetDifficulty(); }
void Awake() { Instance = this; audioSource_ = GetComponent <AudioSource>(); }
private void OnEnable() { musicManager = FindObjectOfType<MusicManagerScript>(); }
void Awake() { Instance = this; DontDestroyOnLoad (gameObject); }
// Use this for initialization void Start() { musicManager = GameObject.FindObjectOfType <MusicManagerScript>(); }
void Awake() { instance = this; }