/// <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); }
/// <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); }