Beispiel #1
0
        /// <summary>
        /// AudioBuddy animates the volume of a 3D sound to linearly fade out to zero or target volume over a set time. AudioBuddySpeakers have additional functionality for custom fades.
        /// </summary>
        /// <param name="abobject"></param>
        /// <param name="location"></param>
        /// <param name="time"></param>
        /// <param name="targetVolume"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker FadeOut(AudioBuddyObject abobject, Vector3 location, float time, float targetVolume = 0f)
        {
            AudioBuddySpeaker speaker = Play(abobject, location);

            speaker.FadeOut(time, targetVolume);
            return(speaker);
        }
Beispiel #2
0
        /// <summary>
        /// AudioBuddy animates the volume of a 3D sound to linearly fade out to zero or target volume over a set time. AudioBuddySpeakers have additional functionality for custom fades.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="speakerPosition"></param>
        /// <param name="time"></param>
        /// <param name="targetVolume"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker FadeOut(string name, GameObject speakerPosition, float time, float targetVolume = 0f)
        {
            AudioBuddySpeaker speaker = Play(name, speakerPosition);

            speaker.FadeOut(time, targetVolume);
            return(speaker);
        }
Beispiel #3
0
        /// <summary>
        /// AudioBuddy animates the volume of a 3D sound to linearly fade out to zero or target volume over a set time. AudioBuddySpeakers have additional functionality for custom fades.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="location"></param>
        /// <param name="time"></param>
        /// <param name="targetVolume"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker FadeOut(string name, Vector3 location, float time, float targetVolume = 0f)
        {
            AudioBuddySpeaker speaker = Play(name, location);

            speaker.FadeOut(time, targetVolume);
            return(speaker);
        }
Beispiel #4
0
        /// <summary>
        /// AudioBuddy animates the volume of a 3D sound to linearly fade in to a target volume over a set time. AudioBuddySpeakers have additional functionality for custom fades.
        /// </summary>
        /// <param name="abobject"></param>
        /// <param name="speakerPosition"></param>
        /// <param name="time"></param>
        /// <param name="targetVolume"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker FadeIn(AudioBuddyObject abobject, GameObject speakerPosition, float time, float targetVolume = 1f)
        {
            AudioBuddySpeaker speaker = Play(abobject, speakerPosition);

            speaker.FadeIn(time, targetVolume);
            return(speaker);
        }
Beispiel #5
0
        //Fades
        /// <summary>
        /// AudioBuddy animates the volume of a 2D sound to linearly fade in to a target volume over a set time. AudioBuddySpeakers have additional functionality for custom fades.
        /// </summary>
        /// <param name="name"></param>
        /// <param name="time"></param>
        /// <param name="targetVolume"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker FadeIn(string name, float time, float targetVolume = 1f)
        {
            AudioBuddySpeaker speaker = Play(name);

            speaker.FadeIn(time, targetVolume);
            return(speaker);
        }
Beispiel #6
0
        public AudioBuddySpeaker Play2D(AudioBuddyObject abobject, float volumeMultiplier)
        {
            AudioBuddySpeaker player = NextAvailablePlayerOrNew();

            player.SourcePlayer.spatialBlend = 0;
            player.PlaySound(abobject, volumeMultiplier);
            return(player);
        }
Beispiel #7
0
        /// <summary>
        /// AudioBuddy attaches a 3D sound to the target GameObject so that the sound moves along with the object
        /// </summary>
        /// <param name="abobject"></param>
        /// <param name="speaker"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker AttachSound(AudioBuddyObject abobject, GameObject speaker)
        {
            AudioSource       source = speaker.AddComponent <AudioSource>();
            AudioBuddySpeaker player = speaker.AddComponent <AudioBuddySpeaker>();

            player.DisableDynamicManagement();
            source.spatialBlend = 1;
            player.PlaySound(abobject, 1f);
            return(player);
        }
Beispiel #8
0
        /// <summary>
        /// AudioBuddy attaches a 3D sound to the target GameObject so that the sound moves along with the object
        /// </summary>
        /// <param name="name"></param>
        /// <param name="volumeMultiplier"></param>
        /// <param name="speaker"></param>
        /// <returns></returns>
        public static AudioBuddySpeaker AttachSound(string name, float volumeMultiplier, GameObject speaker)
        {
            AudioSource       source = speaker.AddComponent <AudioSource>();
            AudioBuddySpeaker player = speaker.AddComponent <AudioBuddySpeaker>();

            player.DisableDynamicManagement();
            player.SourcePlayer = source;
            source.spatialBlend = 1;
            player.PlaySound(FindSoundByName(name), volumeMultiplier);
            return(player);
        }
Beispiel #9
0
        public AudioBuddySpeaker NextAvailablePlayerOrNew()
        {
            AudioBuddySpeaker player = NextAvailablePlayer();

            if (player == null)
            {
                player = Instantiate(SpeakerPrefab, transform).GetComponent <AudioBuddySpeaker>();
                Speakers.Add(player);
            }
            return(player);
        }
Beispiel #10
0
        public AudioBuddySpeaker PlayAtLocation(AudioBuddyObject abobject, float volumeMultiplier, Vector3 location)
        {
            AudioBuddySpeaker player = NextAvailablePlayerOrNew();

            //TODO Rollof
            player.ReassignSpeaker();
            player.SourcePlayer.spatialBlend     = 1;
            player.gameObject.transform.position = location;
            player.PlaySound(abobject, volumeMultiplier);
            return(player);
        }