internal GMAudioOptionsModel Serialize() { return(new GMAudioOptionsModel { id = Id, audioGroups = AudioGroups.Select(x => (GMAudioGroupModel)x.Serialize()).ToList() }); }
public static void PlaySound(AudioClip audioClipToPlay, AudioGroups audioGroups) { GameObject soundGameobject = new GameObject("Sound"); AudioSource audioSource = soundGameobject.AddComponent <AudioSource>(); audioSource.PlayOneShot(audioClipToPlay); soundGameobject.GetComponent <AudioSource>().outputAudioMixerGroup = AudioManager.audioMixer.FindMatchingGroups(audioGroups.ToString())[0]; GameObject.Destroy(soundGameobject, audioClipToPlay.length); }
public static void PlaySound(AudioClip audioClipToPlay, AudioGroups audioGroups, Vector3 position) { GameObject soundObject = new GameObject("Sound"); soundObject.transform.position = position; AudioSource audio = soundObject.AddComponent <AudioSource>(); audio.PlayOneShot(audioClipToPlay); audio.outputAudioMixerGroup = audioMixer.FindMatchingGroups(audioGroups.ToString())[0]; GameObject.Destroy(soundObject, audioClipToPlay.length); }
internal void Deserialize(GMAudioOptionsModel audioOptionsModel) { Id = audioOptionsModel.id; foreach (var modelAudioGroup in audioOptionsModel.audioGroups) { var audioGroup = new GMAudioGroup(); audioGroup.Deserialize(modelAudioGroup); AudioGroups.Add(audioGroup); } }
public static void CreateSFX(AudioClip clip, Vector3 position, AudioGroups audioGroup, float spatialBlend, float rolloffDistanceMin = 1f) { GameObject impactSFXInstance = new GameObject(); impactSFXInstance.transform.position = position; AudioSource source = impactSFXInstance.AddComponent <AudioSource>(); source.clip = clip; source.spatialBlend = spatialBlend; source.minDistance = rolloffDistanceMin; source.Play(); source.outputAudioMixerGroup = GetAudioGroup(audioGroup); }
public static AudioMixerGroup GetAudioGroup(AudioGroups group) { if (m_AudioManager == null) { m_AudioManager = GameObject.FindObjectOfType <AudioManager>(); } var groups = m_AudioManager.audioMixer.FindMatchingGroups(group.ToString()); if (groups.Length > 0) { return(groups[0]); } Debug.LogWarning("Didn't find audio group for " + group.ToString()); return(null); }
public GMAudioGroup CreateAudioGroup(string name) { if (name == null) { throw new ArgumentNullException(nameof(name)); } // TODO Validate name var audioGroup = new GMAudioGroup { Id = Guid.NewGuid(), Name = name }; AudioGroups.Add(audioGroup); return(audioGroup); }
public static void CreateSFX(AudioClip clip, Vector3 position, AudioGroups audioGroup, float spatialBlend, float rolloffDistanceMin = 1f, float rolloffDistanceMax = 500f, float volume = 1f) { GameObject impactSFXInstance = new GameObject(); impactSFXInstance.transform.position = position; AudioSource source = impactSFXInstance.AddComponent <AudioSource>(); source.clip = clip; source.spatialBlend = spatialBlend; source.minDistance = rolloffDistanceMin; source.maxDistance = rolloffDistanceMax; source.volume = volume; source.Play(); source.outputAudioMixerGroup = GetAudioGroup(audioGroup); TimedSelfDestruct timedSelfDestruct = impactSFXInstance.AddComponent <TimedSelfDestruct>(); timedSelfDestruct.lifeTime = clip.length; }
public static void PlaySound(AudioClip audioClipToPlay, Vector3 position, AudioGroups audioGroups) { AudioManager.PlaySound(audioClipToPlay, audioGroups, position); }