1. 程式人生 > >C#延時程式碼

C#延時程式碼

StartCoroutine(StartBGM());


IEnumerator StartBGM(){yield return new WaitForSeconds(0.5f);while(PatternSystem.instance.loadingComplete == false){yield return 0;}Debug.Log("play");bgmSound.Play();}


---------------------------------------------------------分割線----------------------------------------------------------------------


void Update () {//if press any key jump to gameplay sceneif(Input.anyKeyDown){if(!oneshotSfx){AudioSource.PlayClipAtPoint(sfxButton,Vector3.zero);Invoke("LoadScene",0.5f);oneshotSfx = true;}}}void LoadScene(){//load gameplay sceneApplication.LoadLevel("GamePlay");}