Esempio n. 1
0
 void PlayClip(AudioClip clip, int startSample = 0, bool loop = false)
 {
     AudioUtil.StopAllPreviewClips();
     AudioUtil.PlayPreviewClip(clip, startSample, loop);
     m_Clip            = clip;
     s_PlayingInstance = this;
 }
Esempio n. 2
0
        public void OnDisable()
        {
            if (s_PlayingInstance == this)
            {
                AudioUtil.StopAllPreviewClips();
                s_PlayingInstance = null;
            }

            EditorPrefs.SetBool("AutoPlayAudio", s_AutoPlay);

            if (m_PreviewUtility != null)
            {
                m_PreviewUtility.Cleanup();
                m_PreviewUtility = null;
            }

            m_HandleLinesMaterial = null;
        }
Esempio n. 3
0
        public override void OnPreviewSettings()
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }

            AudioClip clip = target as AudioClip;

            m_MultiEditing = targets.Length > 1;

            {
                using (new EditorGUI.DisabledScope(m_MultiEditing && !playing))
                {
                    bool newPlaying = GUILayout.Toggle(playing, s_PlayIcon, EditorStyles.toolbarButton);

                    if (newPlaying != playing)
                    {
                        if (newPlaying)
                        {
                            PlayClip(clip, 0, s_Loop);
                        }
                        else
                        {
                            AudioUtil.StopAllPreviewClips();
                            m_Clip = null;
                        }
                    }
                }

                using (new EditorGUI.DisabledScope(m_MultiEditing))
                {
                    s_AutoPlay = s_AutoPlay && !m_MultiEditing;
                    s_AutoPlay = GUILayout.Toggle(s_AutoPlay, s_AutoPlayIcon, EditorStyles.toolbarButton);
                }

                bool loop = s_Loop;
                s_Loop = GUILayout.Toggle(s_Loop, s_LoopIcon, EditorStyles.toolbarButton);
                if ((loop != s_Loop) && playing)
                {
                    AudioUtil.LoopPreviewClip(s_Loop);
                }
            }
        }
Esempio n. 4
0
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            EditorGUILayout.PropertyField(m_Volume, Styles.Volume);
            EditorGUILayout.PropertyField(m_RolloffScale, Styles.RolloffScale);
            EditorGUILayout.PropertyField(m_DopplerFactor, Styles.DopplerFactor);
            EditorGUILayout.PropertyField(m_DefaultSpeakerMode, Styles.DefaultSpeakerMode);
            EditorGUILayout.PropertyField(m_SampleRate, Styles.SampleRate);
            EditorGUILayout.PropertyField(m_RequestedDSPBufferSize, Styles.DSPBufferSize);
            if (m_RequestedDSPBufferSize.intValue != m_ActualDSPBufferSize.intValue)
            {
                EditorGUILayout.HelpBox(
                    string.Format(Styles.DSPBufferSizeInfo.text,
                                  m_RequestedDSPBufferSize.intValue == 0 ? "default" : m_RequestedDSPBufferSize.intValue.ToString(),
                                  m_ActualDSPBufferSize.intValue),
                    MessageType.Info);
            }
            EditorGUILayout.PropertyField(m_VirtualVoiceCount, Styles.VirtualVoiceCount);
            EditorGUILayout.PropertyField(m_RealVoiceCount, Styles.RealVoiceCount);

            List <string> plugins = new List <string>(AudioSettings.GetSpatializerPluginNames());

            plugins.Insert(0, "None");
            string[] pluginsArray = plugins.ToArray();

            List <GUIContent> pluginsGUIContent = new List <GUIContent>();

            foreach (var s in pluginsArray)
            {
                pluginsGUIContent.Add(new GUIContent(s));
            }

            List <string> ambisonicDecoderPlugins = new List <string>(AudioUtil.GetAmbisonicDecoderPluginNames());

            ambisonicDecoderPlugins.Insert(0, "None");
            string[] ambisonicDecoderPluginsArray = ambisonicDecoderPlugins.ToArray();

            List <GUIContent> ambisonicDecoderPluginsGUIContent = new List <GUIContent>();

            foreach (var s in ambisonicDecoderPluginsArray)
            {
                ambisonicDecoderPluginsGUIContent.Add(new GUIContent(s));
            }

            EditorGUI.BeginChangeCheck();
            int pluginIndex = FindPluginStringIndex(pluginsArray, m_SpatializerPlugin.stringValue);

            pluginIndex = EditorGUILayout.Popup(Styles.SpatializerPlugin, pluginIndex, pluginsGUIContent.ToArray());
            if (EditorGUI.EndChangeCheck())
            {
                if (pluginIndex == 0)
                {
                    m_SpatializerPlugin.stringValue = "";
                }
                else
                {
                    m_SpatializerPlugin.stringValue = pluginsArray[pluginIndex];
                }
            }

            EditorGUI.BeginChangeCheck();
            pluginIndex = FindPluginStringIndex(ambisonicDecoderPluginsArray, m_AmbisonicDecoderPlugin.stringValue);
            pluginIndex = EditorGUILayout.Popup(Styles.AmbisonicDecoderPlugin, pluginIndex, ambisonicDecoderPluginsGUIContent.ToArray());
            if (EditorGUI.EndChangeCheck())
            {
                if (pluginIndex == 0)
                {
                    m_AmbisonicDecoderPlugin.stringValue = "";
                }
                else
                {
                    m_AmbisonicDecoderPlugin.stringValue = ambisonicDecoderPluginsArray[pluginIndex];
                }
            }

            EditorGUI.BeginChangeCheck();

            EditorGUILayout.PropertyField(m_DisableAudio, Styles.DisableAudio);

            if (EditorGUI.EndChangeCheck() && m_DisableAudio.boolValue.Equals(true))
            {
                AudioUtil.StopAllPreviewClips();
            }

            EditorGUILayout.PropertyField(m_EnableOutputSuspension, Styles.EnableOutputSuspension);

            EditorGUILayout.PropertyField(m_VirtualizeEffects, Styles.VirtualizeEffects);

            serializedObject.ApplyModifiedProperties();
        }