示例#1
0
    public static void createAndPlay(string name, Vector3 pos, float volume = 1, bool loop = false)
    {
        Sound sound = findSound(name);

        if (sound == null)
        {
            Debug.Log("can't find audio");
        }


        AudioObj audioObj = AudioObj.createFromPool();

        if (audioObj == null)
        {
            Debug.Log("no more audioObj");
            return;
        }

        audioObj.transform.position = pos;
        AudioSource audioSrc = audioObj.transform.GetComponent <AudioSource>();

        audioSrc.clip   = sound.clip;
        audioSrc.loop   = loop;
        audioSrc.volume = volume;
        audioSrc.Play();
    }
示例#2
0
    public static void initSound()
    {
        Transform helicopterAudio = GameObject.Find("helicopterAudio").transform;

        audioObj = AudioObj.createFromPool(helicopterAudio);

        audioObj.attachSound(Sound.findSound("helicopter"));
    }