Created
November 2, 2017 18:34
-
-
Save tatmos/b4e6ea633c44948dc95aae0de3b4c5fb to your computer and use it in GitHub Desktop.
2016声優ハッカソン「彼氏力お化け屋敷」のSoundManager。ADX2LEで3Dポジションなどオブジェクトにくっつけてる。https://qiita.com/tatmos/items/847ae3b57cebb627cce8
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 { | |
CriAtomSource source; | |
public static SoundManager main = null; | |
void Awake() | |
{ | |
if (main == null) | |
{ | |
if (main != null) | |
{ | |
GameObject.Destroy(main.gameObject); | |
} | |
main = this; | |
GameObject.DontDestroyOnLoad(this.gameObject); | |
} else | |
{ | |
GameObject.Destroy(this.gameObject); | |
return; | |
} | |
} | |
// Use this for initialization | |
void Start () { | |
source = this.gameObject.AddComponent<CriAtomSource>(); | |
} | |
// Update is called once per frame | |
void Update () { | |
} | |
/// <summary> | |
/// 再生関数 | |
/// </summary> | |
/// <param name="cueName">Cue name.</param> | |
/// <param name="atomSource">AtomSourceを渡せばその位置から再生も可能</param> | |
static public void Play(string cueName,CriAtomSource atomSource = null) | |
{ | |
if(atomSource != null) | |
{ | |
//Debug.Log("atomsourceあり" + atomSource.transform.position); | |
atomSource.cueSheet = "CueSheet_0"; | |
atomSource.cueName = cueName; | |
atomSource.use3dPositioning = true; | |
atomSource.Play(); | |
} else { | |
main.source.cueSheet = "CueSheet_0"; | |
main.source.cueName = cueName; | |
main.source.Play(); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment