예제 #1
0
        internal static AudioListenerExtension AddSpatializerExtension(AudioListener listener)
        {
            AudioListenerExtension result;

            if (listener.spatializerExtension != null)
            {
                result = listener.spatializerExtension;
            }
            else
            {
                AudioExtensionManager.RegisterBuiltinDefinitions();
                foreach (AudioSpatializerExtensionDefinition audioSpatializerExtensionDefinition in AudioExtensionManager.m_ListenerSpatializerExtensionDefinitions)
                {
                    if (AudioSettings.GetSpatializerPluginName() == audioSpatializerExtensionDefinition.spatializerName || AudioSettings.GetAmbisonicDecoderPluginName() == audioSpatializerExtensionDefinition.spatializerName)
                    {
                        AudioListenerExtension audioListenerExtension = listener.AddExtension(audioSpatializerExtensionDefinition.definition.GetExtensionType());
                        if (audioListenerExtension != null)
                        {
                            audioListenerExtension.audioListener = listener;
                            listener.spatializerExtension        = audioListenerExtension;
                            AudioExtensionManager.WriteExtensionProperties(audioListenerExtension, audioSpatializerExtensionDefinition.definition.GetExtensionType().Name);
                            return(audioListenerExtension);
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
예제 #2
0
        internal static AudioSourceExtension AddSpatializerExtension(AudioSource source)
        {
            AudioSourceExtension result;

            if (!source.spatialize)
            {
                result = null;
            }
            else if (source.spatializerExtension != null)
            {
                result = source.spatializerExtension;
            }
            else
            {
                AudioExtensionManager.RegisterBuiltinDefinitions();
                foreach (AudioSpatializerExtensionDefinition audioSpatializerExtensionDefinition in AudioExtensionManager.m_SourceSpatializerExtensionDefinitions)
                {
                    if (AudioSettings.GetSpatializerPluginName() == audioSpatializerExtensionDefinition.spatializerName)
                    {
                        AudioSourceExtension audioSourceExtension = source.AddSpatializerExtension(audioSpatializerExtensionDefinition.definition.GetExtensionType());
                        if (audioSourceExtension != null)
                        {
                            audioSourceExtension.audioSource = source;
                            source.spatializerExtension      = audioSourceExtension;
                            AudioExtensionManager.WriteExtensionProperties(audioSourceExtension, audioSpatializerExtensionDefinition.definition.GetExtensionType().Name);
                            return(audioSourceExtension);
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
예제 #3
0
        internal static void Update()
        {
            AudioExtensionManager.RegisterBuiltinDefinitions();
            AudioListener audioListener = AudioExtensionManager.GetAudioListener() as AudioListener;

            if (audioListener != null)
            {
                AudioListenerExtension audioListenerExtension = AudioExtensionManager.AddSpatializerExtension(audioListener);
                if (audioListenerExtension != null)
                {
                    audioListenerExtension.ExtensionUpdate();
                }
            }
            for (int i = 0; i < AudioExtensionManager.m_SourceExtensionsToUpdate.Count; i++)
            {
                AudioExtensionManager.m_SourceExtensionsToUpdate[i].ExtensionUpdate();
            }
            AudioExtensionManager.m_NextStopIndex = ((AudioExtensionManager.m_NextStopIndex < AudioExtensionManager.m_SourceExtensionsToUpdate.Count) ? AudioExtensionManager.m_NextStopIndex : 0);
            int num = (AudioExtensionManager.m_SourceExtensionsToUpdate.Count <= 0) ? 0 : (1 + AudioExtensionManager.m_SourceExtensionsToUpdate.Count / 8);

            for (int j = 0; j < num; j++)
            {
                AudioSourceExtension audioSourceExtension = AudioExtensionManager.m_SourceExtensionsToUpdate[AudioExtensionManager.m_NextStopIndex];
                if (audioSourceExtension.audioSource == null || !audioSourceExtension.audioSource.enabled || !audioSourceExtension.audioSource.isPlaying)
                {
                    audioSourceExtension.Stop();
                    AudioExtensionManager.RemoveExtensionFromManager(audioSourceExtension);
                }
                else
                {
                    AudioExtensionManager.m_NextStopIndex++;
                    AudioExtensionManager.m_NextStopIndex = ((AudioExtensionManager.m_NextStopIndex < AudioExtensionManager.m_SourceExtensionsToUpdate.Count) ? AudioExtensionManager.m_NextStopIndex : 0);
                }
            }
        }
예제 #4
0
        internal static AudioSourceExtension AddAmbisonicDecoderExtension(AudioSource source)
        {
            AudioSourceExtension result;

            if (source.ambisonicExtension != null)
            {
                result = source.ambisonicExtension;
            }
            else
            {
                AudioExtensionManager.RegisterBuiltinDefinitions();
                foreach (AudioAmbisonicExtensionDefinition audioAmbisonicExtensionDefinition in AudioExtensionManager.m_SourceAmbisonicDecoderExtensionDefinitions)
                {
                    if (AudioSettings.GetAmbisonicDecoderPluginName() == audioAmbisonicExtensionDefinition.ambisonicPluginName)
                    {
                        AudioSourceExtension audioSourceExtension = source.AddAmbisonicExtension(audioAmbisonicExtensionDefinition.definition.GetExtensionType());
                        if (audioSourceExtension != null)
                        {
                            audioSourceExtension.audioSource = source;
                            source.ambisonicExtension        = audioSourceExtension;
                            return(audioSourceExtension);
                        }
                    }
                }
                result = null;
            }
            return(result);
        }
예제 #5
0
 internal static void GetReadyToPlay(AudioSourceExtension extension)
 {
     if (extension != null)
     {
         extension.Play();
         AudioExtensionManager.AddExtensionToManager(extension);
     }
 }
예제 #6
0
 internal static void AddExtensionToManager(AudioSourceExtension extension)
 {
     AudioExtensionManager.RegisterBuiltinDefinitions();
     if (extension.m_ExtensionManagerUpdateIndex == -1)
     {
         AudioExtensionManager.m_SourceExtensionsToUpdate.Add(extension);
         extension.m_ExtensionManagerUpdateIndex = AudioExtensionManager.m_SourceExtensionsToUpdate.Count - 1;
     }
 }
예제 #7
0
 public void PlayOneShot(AudioClip clip, [UnityEngine.Internal.DefaultValue("1.0F")] float volumeScale)
 {
     if (clip != null && clip.ambisonic)
     {
         AudioSourceExtension audioSourceExtension = AudioExtensionManager.AddAmbisonicDecoderExtension(this);
         if (audioSourceExtension != null)
         {
             AudioExtensionManager.GetReadyToPlay(audioSourceExtension);
         }
     }
     this.PlayOneShotHelper(clip, volumeScale);
 }
예제 #8
0
 public void OnDestroy()
 {
     this.Stop();
     AudioExtensionManager.RemoveExtensionFromManager(this);
     if (this.audioSource != null)
     {
         if (this.audioSource.spatializerExtension == this)
         {
             this.audioSource.spatializerExtension = null;
         }
         if (this.audioSource.ambisonicExtension == this)
         {
             this.audioSource.ambisonicExtension = null;
         }
     }
 }
예제 #9
0
        internal static void InvokeOnAudioSourcePlay(AudioSource source)
        {
            AudioSourceExtension audioSourceExtension = AudioExtensionManager.AddSpatializerExtension(source);

            if (audioSourceExtension != null)
            {
                AudioExtensionManager.GetReadyToPlay(audioSourceExtension);
            }
            if (source.clip != null && source.clip.ambisonic)
            {
                AudioSourceExtension audioSourceExtension2 = AudioExtensionManager.AddAmbisonicDecoderExtension(source);
                if (audioSourceExtension2 != null)
                {
                    AudioExtensionManager.GetReadyToPlay(audioSourceExtension2);
                }
            }
        }
예제 #10
0
 internal static void InvokeOnAudioManagerUpdate()
 {
     AudioExtensionManager.Update();
 }