LoginSignup
1
1

More than 5 years have passed since last update.

ADX2 LEでのBGMポーズ処理

Posted at

あるクラスで流したBGMを、ポーズ用のクラスから一時停止させる方法。

ココ↓
UnityでADX2 LE用のSoundManagerを作成してみた
で作成したSoundManagerを使用する。

実行環境

・Windows 10
・Unity 5.4.0f3
・音関係はADX2 LEで管理

BGMを再生する処理が入っているクラスの一部分

hogehoge.cs
 public static SoundManager sm; // staticとすることで、他のクラスから参照

 void Start(){
   sm = gameObject.GetComponent<SoundManager>();
   sm.PlayBGM("sample"); //ここでBGMを流す
 }

ここでは、初期化時点でBGMを流す処理をしている。

ポーズ処理用のクラス

PauseMenu.cs
using UnityEngine;
using System.Collections;
using UnityEngine.UI;

public class PauseMenu : MonoBehaviour {

    public void OnPauseMenu() { // ポーズメニューをしたときの処理を記述(ここでは、BGM一時停止のみ)
        hogehoge.sm.PauseBGM(); // BGMを一時停止
    }

}

あまりstaticは使用したくないが、手軽な感じでの実装方法。
staticなので、hogehogeクラスを参照
テスト用に実装するなら、uGUIでボタンを作成し、ボタンの動作をOnPauseMenu()と結びつければ、確認できる。

1
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
1
1