SoundManager.csUnity記事: 目次
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
using UnityEngine; /// <summary> /// /// Unity 2018.2.8f1 /// /// </summary> public class SoundManager : MonoBehaviour { // Inspector [SerializeField] private AudioSource audioSourceComponent; [SerializeField] private AudioClip BGM; // Use this for initialization private void Start() { // BGMを音量1.0で再生 Play(BGM, 1.0f); } // 1. 再生 private void Play(AudioClip audioClip, float volume) { // AudioClip audioSourceComponent.clip = audioClip; // 音量 audioSourceComponent.volume = volume; // 再生 audioSourceComponent.Play(); } // 2. 一時停止 private void Pause() { audioSourceComponent.Pause(); } // 3. 停止 private void Stop() { audioSourceComponent.Stop(); } } |