Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        // Check to see if we need to add a spatializer extension to this audio source, based on the currently-registered extensions.
        static internal AudioSourceExtension AddSpatializerExtension(AudioSource source)
        {
            if (!source.spatialize)
            {
                return(null);
            }

            if (source.spatializerExtension != null)
            {
                return(source.spatializerExtension);
            }

            RegisterBuiltinDefinitions();

            foreach (AudioSpatializerExtensionDefinition extensionDefinition in m_SourceSpatializerExtensionDefinitions)
            {
                if (AudioSettings.GetSpatializerPluginName() == extensionDefinition.spatializerName)
                {
                    AudioSourceExtension newExtension = source.AddSpatializerExtension(extensionDefinition.definition.GetExtensionType());
                    if (newExtension != null)
                    {
                        newExtension.audioSource    = source;
                        source.spatializerExtension = newExtension;

                        WriteExtensionProperties(newExtension, extensionDefinition.definition.GetExtensionType().Name);
                        return(newExtension);
                    }
                }
            }

            return(null);
        }