Created
November 2, 2017 19:13
-
-
Save tatmos/bdfa8d55ee1206798548ac796f368c70 to your computer and use it in GitHub Desktop.
2014年「壁ドン」のSoundManager。ADX2LEのほとんど再生だけしかしてない。
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using UnityEngine; | |
using System.Collections; | |
public class SoundManager : MonoBehaviour { | |
public static SoundManager ssm;//SingletoneSoundManager | |
CriAtomSource[] seSource; //SE再生用 | |
CriAtomSource[] bgmSource; //BGM再生用 | |
int seSourceMaxNum = 2; //SEの最大発音数 | |
// Use this for initialization | |
void Awake () { | |
if(SoundManager.ssm != null){ | |
//Debug.Log("Sound:Destroy "); | |
GameObject.Destroy(this.gameObject); // | |
return; | |
} | |
seSource = new CriAtomSource[seSourceMaxNum]; //SEのソース作成 | |
for(int i = 0;i<seSourceMaxNum;i++){ | |
seSource[i] = gameObject.AddComponent<CriAtomSource>(); | |
seSource[i].cueSheet = "CueSheet_0"; | |
} | |
bgmSource = new CriAtomSource[seSourceMaxNum]; //BGMのソース作成 | |
for(int i = 0;i<seSourceMaxNum;i++){ | |
bgmSource[i] = gameObject.AddComponent<CriAtomSource>(); | |
bgmSource[i].cueSheet = "CueSheet_0"; | |
} | |
DontDestroyOnLoad(this); | |
SoundManager.ssm = this;//シングルトンサウンドマネージャを登録 | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
public void PlaySE(string name) | |
{ | |
seSource[0].cueName = name; | |
seSource[0].Play(); | |
} | |
public void PlayBGM(string name) | |
{ | |
//Debug.Log("Sound:PlayBGM " + name.ToString()); | |
//Debug.Log("Sound:Still Playing " + bgmSource[0].cueName.ToString()); | |
if(bgmSource[0].status == CriAtomSource.Status.Playing) | |
{ | |
if(bgmSource[0].cueName == name) | |
{ | |
// nothing (still playing) | |
return; | |
} | |
} | |
bgmSource[0].cueName = name; | |
bgmSource[0].Play(); | |
} | |
public bool debugFlag = true; | |
void OnGUI() | |
{ | |
if(debugFlag){ | |
//GUILayout.BeginHorizontal(); | |
if(GUILayout.Button("don")){ | |
SoundManager.ssm.PlaySE("don"); | |
} | |
if(GUILayout.Button("yokeru")){ | |
SoundManager.ssm.PlaySE("yokeru"); | |
} | |
if(GUILayout.Button("applause")){ | |
SoundManager.ssm.PlaySE("applause"); | |
} | |
if(GUILayout.Button("ageUp")){ | |
SoundManager.ssm.PlaySE("ageUp"); | |
} | |
if(GUILayout.Button("kill")){ | |
SoundManager.ssm.PlaySE("kill"); | |
} | |
if(GUILayout.Button("voice_konobokunai")){ | |
SoundManager.ssm.PlaySE("voice_konobokunai"); | |
} | |
if(GUILayout.Button("voice_yatokimisuki")){ | |
SoundManager.ssm.PlaySE("voice_yatokimisuki"); | |
} | |
if(GUILayout.Button("okuri")){ | |
SoundManager.ssm.PlaySE("okuri"); | |
} | |
if(GUILayout.Button("unazuku")){ | |
SoundManager.ssm.PlaySE("unazuku"); | |
} | |
if(GUILayout.Button("bgm1")){ | |
SoundManager.ssm.PlayBGM("bgm1"); | |
} | |
if(GUILayout.Button("bgm2")){ | |
SoundManager.ssm.PlayBGM("bgm2"); | |
} | |
if(GUILayout.Button("bgm3")){ | |
SoundManager.ssm.PlayBGM("bgm3"); | |
} | |
//GUILayout.EndHorizontal(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment