void OnDestroy() { PluginAudio.audioDestroyUserPlayer(bgm0_); bgm0_ = System.IntPtr.Zero; PluginAudio.audioTerminate(); }
void Start() { se1_ = (GameObject.Instantiate(se1Prefab_) as GameObject).GetComponent <AudioSource>(); bgm1_ = (GameObject.Instantiate(bgm1Prefab_) as GameObject).GetComponent <AudioSource>(); bgm1_.loop = true; Vector3 pos = new Vector3(-4.0f, 0.0f, 0.0f); for (int i = 0; i < 2; ++i) { circles_[i].sprite_ = GameObject.Instantiate(circlePrefab_) as GameObject; circles_[i].sprite_.transform.localPosition = pos; circles_[i].sprite_.SetActive(false); pos.x += 8.0f; } toggleBGM_.onClick.AddListener(onClickToggleBGM); PluginAudio.audioInitialize(); PluginAudio.loadResourcePackFromAsset(0, "bgm.pak", true); PluginAudio.loadResourcePackFromAsset(1, "se.pak", false); bgm0_ = PluginAudio.audioCreateUserPlayer(0, 0); PluginAudio.audioUserPlayerPlay(bgm0_); textBGM_.text = BGMInfoOpus; }
void play(int index) { switch (index) { case 0: PluginAudio.audioPlay(1, 0, 1.0f); break; case 1: se1_.PlayOneShot(se1_.clip); break; } }
void onClickToggleBGM() { if (playBGMOpus_) { playBGMOpus_ = false; toggleBGM_.GetComponentInChildren <Text>().text = "BGM UNITY NOW"; PluginAudio.audioUserPlayerPause(bgm0_); bgm1_.Play(); textBGM_.text = BGMInfoUnity; } else { playBGMOpus_ = true; toggleBGM_.GetComponentInChildren <Text>().text = "BGM OPUS NOW"; PluginAudio.audioUserPlayerPlay(bgm0_); bgm1_.Pause(); textBGM_.text = BGMInfoOpus; } }
void LateUpdate() { PluginAudio.audioProc(); }
void OnApplicationPause(bool pause) { PluginAudio.audioPause(pause); }