Exemplo n.º 1
0
    public void PlaySound(string name)
    {
        if (OptionsInterface.IsOpenSound())
        {
            AudioClip clip = LoadSound(name);

            GameObject obj = new GameObject("AudioSound::" + clip.name);
            obj.transform.parent = transform;

            AudioSource source = obj.AddComponent(typeof(AudioSource)) as AudioSource;
            source.clip = clip;
            source.Play();
            source.playOnAwake = false;
            Destroy(obj, clip.length);
        }
    }
Exemplo n.º 2
0
    public void PlayMusic(string name)
    {
        if (OptionsInterface.IsOpenMusic())
        {
            AudioClip clip = LoadMusic(name);

            GameObject obj = new GameObject("AudioMusic::" + clip.name);
            obj.transform.parent = transform;

            AudioSource source = obj.AddComponent(typeof(AudioSource)) as AudioSource;
            source.clip        = clip;
            source.loop        = true;
            source.playOnAwake = false;
            source.Play();
        }
    }