Example #1
0
        private void CreateExtensionEditors()
        {
            if (this.m_SpatializerEditor != null)
            {
                this.DestroyExtensionEditors();
            }
            Type listenerSpatializerExtensionEditorType = AudioExtensionManager.GetListenerSpatializerExtensionEditorType();

            this.m_SpatializerEditor = (ScriptableObject.CreateInstance(listenerSpatializerExtensionEditorType) as AudioListenerExtensionEditor);
            if (this.m_SpatializerEditor != null)
            {
                for (int i = 0; i < base.targets.Length; i++)
                {
                    AudioListener audioListener = base.targets[i] as AudioListener;
                    if (audioListener != null)
                    {
                        Undo.RecordObject(audioListener, "Add AudioListener extension properties");
                        PropertyName listenerSpatializerExtensionName = AudioExtensionManager.GetListenerSpatializerExtensionName();
                        for (int j = 0; j < this.m_SpatializerEditor.GetNumExtensionProperties(); j++)
                        {
                            PropertyName extensionPropertyName = this.m_SpatializerEditor.GetExtensionPropertyName(j);
                            float        propertyValue         = 0f;
                            if (!audioListener.ReadExtensionProperty(listenerSpatializerExtensionName, extensionPropertyName, ref propertyValue))
                            {
                                propertyValue = this.m_SpatializerEditor.GetExtensionPropertyDefaultValue(j);
                                audioListener.WriteExtensionProperty(AudioExtensionManager.GetSpatializerName(), listenerSpatializerExtensionName, extensionPropertyName, propertyValue);
                            }
                        }
                    }
                }
            }
            this.m_AddSpatializerExtensionMixedValues = false;
        }
        // Created editors for all the enabled extensions of this AudioSource.
        private void CreateExtensionEditors()
        {
            if (m_SpatializerEditor != null)
            {
                DestroyExtensionEditors();
            }

            System.Type spatializerEditorType = AudioExtensionManager.GetListenerSpatializerExtensionEditorType();
            m_SpatializerEditor = ScriptableObject.CreateInstance(spatializerEditorType) as AudioListenerExtensionEditor;

            if (m_SpatializerEditor != null)
            {
                for (int i = 0; i < targets.Length; i++)
                {
                    AudioListener listener = targets[i] as AudioListener;
                    if (listener != null)
                    {
                        Undo.RecordObject(listener, "Add AudioListener extension properties");
                        PropertyName extensionName = AudioExtensionManager.GetListenerSpatializerExtensionName();
                        for (int j = 0; j < m_SpatializerEditor.GetNumExtensionProperties(); j++)
                        {
                            PropertyName propertyName = m_SpatializerEditor.GetExtensionPropertyName(j);
                            float        value        = 0.0f;

                            // If the AudioListener is missing an extension property, then create it now.
                            if (!listener.ReadExtensionProperty(extensionName, propertyName, ref value))
                            {
                                value = m_SpatializerEditor.GetExtensionPropertyDefaultValue(j);
                                listener.WriteExtensionProperty(AudioExtensionManager.GetSpatializerName(), extensionName, propertyName, value);
                            }
                        }
                    }
                }
            }

            m_AddSpatializerExtensionMixedValues = false;
        }