void Start() { audioSource = GetComponent <AudioSource>(); if (leftTimeBar == null) { this.leftTimeBar = GameObject.Find("LeftTimeBar"); } if (countDownText == null) { this.countDownText = GameObject.Find("CountDown"); } if (player == null) { this.player = GameObject.Find("Player"); } if (finishText == null) { this.finishText = GameObject.Find("Finish"); } if (gameDirector == null) { this.gameDirector = GameObject.Find("GameDirector"); } playerScript = player.GetComponent <GamePlayerController>(); calcPointScript = gameDirector.GetComponent <CalcPoint>(); BGM = GameObject.Find("BGM"); musicScript = BGM.GetComponent <BackGroundMusic>(); startFlag = false; coroutineFlag = true; deltaTime = 0; }
private void Awake() { gameEnded = false; Time.timeScale = 1f; playerRef = GameObject.FindGameObjectWithTag("Player").GetComponent <PlayerHandler>(); gameUI = gameObject.GetComponent <UIHandler>(); BackGroundMusic.PlayNewAudio(BackGroundMusic.instance.inGameBGM); }
public void MuteInMain() { BackGroundMusic instance = BackGroundMusic.Instance; if (instance != null) { instance.Mute(); } }
void Start() { if (instance) { Destroy(gameObject); } else { instance = this; GameObject.DontDestroyOnLoad(gameObject); } }
private AudioClip FindClip(BackGroundMusic soundName) { foreach (SoundClip soundClip in soundClips) { if (soundClip.soundName == soundName) { return(soundClip.audioClip); } } print("No such clip"); return(null); }
void Awake() { if (backgroundMusic == null) { backgroundMusic = this; DontDestroyOnLoad(backgroundMusic); } else { Destroy(gameObject); } }
// Use this for initialization void Start() { width = Screen.width; height = Screen.height; music = BackGroundMusic.Instance; if(PlayerPrefs.GetInt("background_music") > 0){ music.Play(); }else{ music.Stop(); } }
public void GoHome() { print("LoadMode"); orsom.instance.enabled = true; BackGroundMusic instance = BackGroundMusic.Instance; if (instance != null) { instance.Mute(); } SceneManager.LoadScene(0); }
// Update is called once per frame void MakeSingleton() { if (instance != null) { Destroy(gameObject); } else { instance = this; DontDestroyOnLoad(gameObject); } }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); }
void Awake() { if (instance != null && instance != this) { Destroy(this.gameObject); return; } else { instance = this; } DontDestroyOnLoad(this.gameObject); //SceneManager.sceneLoaded += OnSceneLoaded; }
private void Awake() { DontDestroyOnLoad(transform.gameObject); // onlu one instance of background sound if (bgmInstance == null) { bgmInstance = this; } else { Destroy(gameObject); } }
private void Awake() { GameObject[] gameObjects = GameObject.FindGameObjectsWithTag("music"); if (gameObjects.Length > 1) { Destroy(this.gameObject); } else { instance = this; } DontDestroyOnLoad(this.gameObject); print("started on awake music"); }
public void PlayClip(BackGroundMusic soundName) { if (soundName == actualClip) { return; } AudioClip audioClip = FindClip(soundName); if (audioClip != null) { audioSource.clip = audioClip; actualClip = soundName; audioSource.Play(); } }
public IEnumerator FadeIntoAmbientMusic() { yield return(new WaitForSeconds(1)); StartCoroutine(StartFade(1, 0)); while (audioSource.volume > 0) { yield return(null); } audioSource.clip = FindClip(BackGroundMusic.AmbientMusic); actualClip = BackGroundMusic.AmbientMusic; audioSource.Play(); StartCoroutine(StartFade(5, 0.25f)); }
public void PlayOneShot(BackGroundMusic sound, float volumeScale = 1) { BGMSource.PlayOneShot(BackGroundSound[sound], volumeScale * 1); }
public void SetMainMenuBGM() { BackGroundMusic.PlayNewAudio(BackGroundMusic.instance.mainMenu); }