Beispiel #1
0
    public void Awake()
    {
        bgm = gameObject.AddComponent<CriAtomSource>();
        bgm.cueSheet = cueSheetName;

        Button startButton = transform.FindChild("StartButton").GetComponent<Button>();
        Button stopButton = transform.FindChild("StopButton").GetComponent<Button>();
        startButton.onClick.AsObservable()
            .Subscribe(_ =>
            {
                if (bgm.IsPaused())
                {
                    bgm.Pause(false);
                } else
                {
                    Debug.Log("play!!");
                    bgm.Play(cueName);
                }
            });
        stopButton.onClick.AsObservable()
            .Subscribe(_ =>
            {
                if (!bgm.IsPaused())
                {
                    bgm.Pause(true);
                }
            });
    }
 public void PlayBgm()
 {
     if (bgmSource.IsPaused())
     {
         bgmSource.Pause(false);
     }
     else
     {
         bgmSource.Play(cueSheet.name);
     }
 }