Skip to content

Instantly share code, notes, and snippets.

@TakaakiIchijo
Last active August 29, 2015 14:04
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save TakaakiIchijo/6b64234d2238ce25451e to your computer and use it in GitHub Desktop.
Save TakaakiIchijo/6b64234d2238ce25451e to your computer and use it in GitHub Desktop.
using UnityEngine;
public class UIPlayAtom : MonoBehaviour
{
public string cueName; //再生するキュー名//
public string cueSheet; //再生するキューが入ったキューシート名//
public float volume;
public flota pitch;
static CriAtomSource atomSourceNGUI;
static CriAtomListener atomListenerNGUI;
Camera cam;
void Awake()
{
cam = Camera.main;
if (cam == null)
cam = GameObject.FindObjectOfType(typeof(Camera)) as Camera;
//createAtomListener//
atomListenerNGUI = cam.gameObject.GetComponent<CriAtomListener>();
if(atomListenerNGUI == null)
atomListenerNGUI = cam.gameObject.AddComponent<CriAtomListener>();
//createAtomSource//
atomSourceNGUI = cam.gameObject.GetComponent<CriAtomSource>();
if(atomSourceNGUI == null)
atomSourceNGUI = cam.gameObject.AddComponent<CriAtomSource>();
if (cueSheet != null)
atomSourceNGUI.cueSheet = this.cueSheet;
}
//NGUITools.PlaySound(audioClip, volume, pitch);の部分をPlayCue ();に差し替える//
public void PlayCue ()
{
atomSourceNGUI.volume = this.volume;
atomSourceNGUI.pitch = this.pitch;
atomSourceNGUI.Play(cueName);
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment