示例#1
0
 internal GMAudioOptionsModel Serialize()
 {
     return(new GMAudioOptionsModel
     {
         id = Id,
         audioGroups = AudioGroups.Select(x => (GMAudioGroupModel)x.Serialize()).ToList()
     });
 }
示例#2
0
    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);
    }
示例#3
0
    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);
    }
示例#4
0
        internal void Deserialize(GMAudioOptionsModel audioOptionsModel)
        {
            Id = audioOptionsModel.id;

            foreach (var modelAudioGroup in audioOptionsModel.audioGroups)
            {
                var audioGroup = new GMAudioGroup();
                audioGroup.Deserialize(modelAudioGroup);
                AudioGroups.Add(audioGroup);
            }
        }
示例#5
0
    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);
    }
示例#6
0
    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);
    }
示例#7
0
        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;
    }
示例#9
0
 public static void PlaySound(AudioClip audioClipToPlay, Vector3 position, AudioGroups audioGroups)
 {
     AudioManager.PlaySound(audioClipToPlay, audioGroups, position);
 }