Beispiel #1
0
    public bool StopSound(AudioClipManaged audioClipName)
    {
        // check each audio element in the list of audioClips
        //audioSourceSound.Stop ();
        // get the clip from the audioClips list
        // get the clip from the audioClips list
        AudioClip clip = GetAudioClipByName(audioClipName);

        foreach (KeyValuePair <System.Guid, AudioSource> element in globalAudioSourceDictionary)
        {
            if (element.Value != null && element.Value.clip != null)
            {
                if (clip.name == element.Value.clip.name)
                {
                    // element has been found, stop it
                    element.Value.Stop();
                    element.Value.loop = false;
                    return(true);
                }
            }
        }

        // loop is finished, no audio has been found
        return(false);
    }
Beispiel #2
0
    public AudioClip GetAudioClipByName(AudioClipManaged soundName)
    {
        foreach (SoundSummary audioSummary in this.audioClips)
        {
            if (audioSummary.name == soundName)
            {
                return(audioSummary.clip);
            }
        }

        // no clip could be found, return an empty one
        return(new AudioClip());
    }
Beispiel #3
0
    public bool IsAudioSoundPlaying(AudioClipManaged audioClipName, GameObject go)
    {
        AudioClip clip = GetAudioClipByName(audioClipName);

        foreach (AudioSource audioSource in go.GetComponents <AudioSource>())
        {
            if (clip.name == audioSource.clip.name)
            {
                return(audioSource.isPlaying);
            }
        }

        return(false);
    }
Beispiel #4
0
    public bool StopSound(AudioClipManaged audioClipName, GameObject go)
    {
        AudioClip clip = GetAudioClipByName(audioClipName);

        foreach (AudioSource audioSource in go.GetComponents <AudioSource>())
        {
            if (clip.name == audioSource.clip.name)
            {
                audioSource.Stop();
            }
        }

        return(false);
    }
Beispiel #5
0
    public bool IsAudioSoundPlaying(AudioClipManaged audioClipName)
    {
        // get the clip from the audioClips list
        AudioClip clip = GetAudioClipByName(audioClipName);

        foreach (KeyValuePair <System.Guid, AudioSource> element in globalAudioSourceDictionary)
        {
            if (element.Value != null && element.Value.clip != null)
            {
                if (clip.name == element.Value.clip.name)
                {
                    // element has been found, return the state of isPlaying
                    return(element.Value.isPlaying);
                }
            }
        }

        return(false);
    }
Beispiel #6
0
    public System.Guid Play(AudioClipManaged clipName, GameObject go = null)
    {
        // check each audio element in the list of audioClips
        foreach (SoundSummary audioSummary in this.audioClips)
        {
            // compare the name with the passed parameter's name
            if (audioSummary.name == clipName)
            {
                if (go != null)
                {
                    // anheften an go
                    return(CreateAndPlayNewAudioSource(audioSummary, go));
                }
                else
                {
                    return(CreateAndPlayNewAudioSource(audioSummary, AudioManager.GetScriptObject()));
                    // an den spieler anhefeten
                }
            }
        }

        // loop is finished, no audio has been found
        return(System.Guid.NewGuid());
    }