public static float[] GetOverviewFor(AudioClip clip)
 {
     float[] result;
     if (!StreamedAudioClipPreview.AudioClipMinMaxOverview.s_Data.ContainsKey(clip))
     {
         string assetPath = AssetDatabase.GetAssetPath(clip);
         if (assetPath == null)
         {
             result = null;
             return(result);
         }
         AssetImporter atPath = AssetImporter.GetAtPath(assetPath);
         if (atPath == null)
         {
             result = null;
             return(result);
         }
         StreamedAudioClipPreview.AudioClipMinMaxOverview.s_Data[clip] = AudioUtil.GetMinMaxData(atPath as AudioImporter);
     }
     result = StreamedAudioClipPreview.AudioClipMinMaxOverview.s_Data[clip];
     return(result);
 }
        private void DoRenderPreview(AudioClip clip, AudioImporter audioImporter, Rect wantedRect, float scaleFactor)
        {
            scaleFactor *= 0.95f;
            float[] minMaxData  = (!(audioImporter == null)) ? AudioUtil.GetMinMaxData(audioImporter) : null;
            int     numChannels = clip.channels;
            int     numSamples  = (minMaxData != null) ? (minMaxData.Length / (2 * numChannels)) : 0;
            float   num         = wantedRect.height / (float)numChannels;
            int     channel;

            for (channel = 0; channel < numChannels; channel++)
            {
                Rect  r          = new Rect(wantedRect.x, wantedRect.y + num * (float)channel, wantedRect.width, num);
                Color curveColor = new Color(1f, 0.549019635f, 0f, 1f);
                AudioCurveRendering.DrawMinMaxFilledCurve(r, delegate(float x, out Color col, out float minValue, out float maxValue)
                {
                    col = curveColor;
                    if (numSamples <= 0)
                    {
                        minValue = 0f;
                        maxValue = 0f;
                    }
                    else
                    {
                        float f  = Mathf.Clamp(x * (float)(numSamples - 2), 0f, (float)(numSamples - 2));
                        int num2 = (int)Mathf.Floor(f);
                        int num3 = (num2 * numChannels + channel) * 2;
                        int num4 = num3 + numChannels * 2;
                        minValue = Mathf.Min(minMaxData[num3 + 1], minMaxData[num4 + 1]) * scaleFactor;
                        maxValue = Mathf.Max(minMaxData[num3], minMaxData[num4]) * scaleFactor;
                        if (minValue > maxValue)
                        {
                            float num5 = minValue;
                            minValue   = maxValue;
                            maxValue   = num5;
                        }
                    }
                });
            }
        }
        public override void OnInspectorGUI()
        {
            if (IsMissingMonoBehaviourTarget() && MissingMonoBehaviourGUI())
            {
                return;
            }

            base.OnInspectorGUI();

            if (target is MonoBehaviour)
            {
                // Does this have a AudioRead callback?
                if (AudioUtil.HasAudioCallback(target as MonoBehaviour) && AudioUtil.GetCustomFilterChannelCount(target as MonoBehaviour) > 0)
                {
                    if (m_AudioFilterGUI == null)
                    {
                        m_AudioFilterGUI = new AudioFilterGUI();
                    }
                    m_AudioFilterGUI.DrawAudioFilterGUI(target as MonoBehaviour);
                }
            }
        }
Exemple #4
0
        public void DrawAudioFilterGUI(MonoBehaviour behaviour)
        {
            int customFilterChannelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);

            if (customFilterChannelCount > 0)
            {
                if (this.dataOut == null)
                {
                    this.dataOut = new EditorGUI.VUMeter.SmoothingData[customFilterChannelCount];
                }
                double num  = (double)AudioUtil.GetCustomFilterProcessTime(behaviour) / 1000000.0;
                float  num2 = (float)num / ((float)AudioSettings.outputSampleRate / 1024f / (float)customFilterChannelCount);
                GUILayout.BeginHorizontal(new GUILayoutOption[0]);
                GUILayout.Space(13f);
                GUILayout.BeginVertical(new GUILayoutOption[0]);
                EditorGUILayout.Space();
                for (int i = 0; i < customFilterChannelCount; i++)
                {
                    EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, i), ref this.dataOut[i], new GUILayoutOption[]
                    {
                        GUILayout.MinWidth(50f),
                        GUILayout.Height(5f)
                    });
                }
                GUILayout.EndVertical();
                Color color = GUI.color;
                GUI.color = new Color(num2, 1f - num2, 0f, 1f);
                GUILayout.Box(string.Format("{0:00.00}ms", num), new GUILayoutOption[]
                {
                    GUILayout.MinWidth(40f),
                    GUILayout.Height(20f)
                });
                GUI.color = color;
                GUILayout.EndHorizontal();
                EditorGUILayout.Space();
                GUIView.current.Repaint();
            }
        }
Exemple #5
0
        internal bool DoDrawDefaultInspector()
        {
            bool res;

            using (new UnityEditor.Localization.Editor.LocalizationGroup(target))
            {
                res = DoDrawDefaultInspector(serializedObject);

                var behaviour = target as MonoBehaviour;
                if (behaviour == null || !AudioUtil.HasAudioCallback(behaviour) || AudioUtil.GetCustomFilterChannelCount(behaviour) <= 0)
                {
                    return(res);
                }

                // If we have an OnAudioFilterRead callback, draw vu meter
                if (m_AudioFilterGUI == null)
                {
                    m_AudioFilterGUI = new AudioFilterGUI();
                }
                m_AudioFilterGUI.DrawAudioFilterGUI(behaviour);
            }
            return(res);
        }
        public void DrawAudioFilterGUI(MonoBehaviour behaviour)
        {
            int filterChannelCount = AudioUtil.GetCustomFilterChannelCount(behaviour);

            if (filterChannelCount <= 0)
            {
                return;
            }
            if (this.dataOut == null)
            {
                this.dataOut = new EditorGUI.VUMeter.SmoothingData[filterChannelCount];
            }
            double num = (double)AudioUtil.GetCustomFilterProcessTime(behaviour) / 1000000.0;
            float  r   = (float)num / ((float)AudioSettings.outputSampleRate / 1024f / (float)filterChannelCount);

            GUILayout.BeginHorizontal();
            GUILayout.Space(13f);
            GUILayout.BeginVertical();
            EditorGUILayout.Space();
            for (int channel = 0; channel < filterChannelCount; ++channel)
            {
                EditorGUILayout.VUMeterHorizontal(AudioUtil.GetCustomFilterMaxOut(behaviour, channel), ref this.dataOut[channel], GUILayout.MinWidth(50f), GUILayout.Height(5f));
            }
            GUILayout.EndVertical();
            Color color = GUI.color;

            GUI.color = new Color(r, 1f - r, 0.0f, 1f);
            GUILayout.Box(string.Format("{0:00.00}ms", (object)num), new GUILayoutOption[2]
            {
                GUILayout.MinWidth(40f),
                GUILayout.Height(20f)
            });
            GUI.color = color;
            GUILayout.EndHorizontal();
            EditorGUILayout.Space();
            GUIView.current.Repaint();
        }
Exemple #7
0
        public override void OnInspectorGUI()
        {
            if (ObjectIsMonoBehaviourOrScriptableObject(target) && MissingMonoBehaviourGUI())
            {
                return;
            }

            base.OnInspectorGUI();

            var behaviour = target as MonoBehaviour;

            if (behaviour != null)
            {
                // Does this have a AudioRead callback?
                if (AudioUtil.HasAudioCallback(behaviour) && AudioUtil.GetCustomFilterChannelCount(behaviour) > 0)
                {
                    if (m_AudioFilterGUI == null)
                    {
                        m_AudioFilterGUI = new AudioFilterGUI();
                    }
                    m_AudioFilterGUI.DrawAudioFilterGUI(behaviour);
                }
            }
        }
        public override string GetInfoString()
        {
            AudioClip clip         = base.target as AudioClip;
            int       channelCount = AudioUtil.GetChannelCount(clip);
            string    text         = (channelCount != 1) ? ((channelCount != 2) ? ((channelCount - 1).ToString() + ".1") : "Stereo") : "Mono";
            AudioCompressionFormat targetPlatformSoundCompressionFormat = AudioUtil.GetTargetPlatformSoundCompressionFormat(clip);
            AudioCompressionFormat soundCompressionFormat = AudioUtil.GetSoundCompressionFormat(clip);
            string text2 = targetPlatformSoundCompressionFormat.ToString();

            if (targetPlatformSoundCompressionFormat != soundCompressionFormat)
            {
                text2 = text2 + " (" + soundCompressionFormat.ToString() + " in editor)";
            }
            string text3 = text2;

            text2 = string.Concat(new object[]
            {
                text3,
                ", ",
                AudioUtil.GetFrequency(clip),
                " Hz, ",
                text,
                ", "
            });
            TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)AudioUtil.GetDuration(clip));

            if ((uint)AudioUtil.GetDuration(clip) == 4294967295u)
            {
                text2 += "Unlimited";
            }
            else
            {
                text2 += string.Format("{0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds);
            }
            return(text2);
        }
 public override void OnInspectorGUI()
 {
     if (this.IsMissingMonoBehaviourTarget() && this.MissingMonoBehaviourGUI())
     {
         return;
     }
     base.OnInspectorGUI();
     if (this.target is MonoBehaviour && AudioUtil.HaveAudioCallback(this.target as MonoBehaviour) && AudioUtil.GetCustomFilterChannelCount(this.target as MonoBehaviour) > 0)
     {
         if (this.m_AudioFilterGUI == null)
         {
             this.m_AudioFilterGUI = new AudioFilterGUI();
         }
         this.m_AudioFilterGUI.DrawAudioFilterGUI(this.target as MonoBehaviour);
     }
 }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if ((UnityEngine.Object)AudioClipInspector.s_DefaultIcon == (UnityEngine.Object)null)
            {
                AudioClipInspector.Init();
            }
            AudioClip target  = this.target as AudioClip;
            Event     current = Event.current;

            if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used)
            {
                int num = AudioUtil.GetSampleCount(target) / (int)r.width;
                switch (current.type)
                {
                case EventType.MouseDown:
                case EventType.MouseDrag:
                    if (!r.Contains(current.mousePosition) || AudioUtil.IsMovieAudio(target))
                    {
                        break;
                    }
                    if ((UnityEngine.Object) this.m_PlayingClip != (UnityEngine.Object)target)
                    {
                        AudioUtil.StopAllClips();
                        AudioUtil.PlayClip(target, 0, AudioClipInspector.m_bLoop);
                        this.m_PlayingClip = target;
                    }
                    AudioUtil.SetClipSamplePosition(target, num * (int)current.mousePosition.x);
                    current.Use();
                    break;
                }
            }
            else
            {
                if (Event.current.type == EventType.Repaint)
                {
                    background.Draw(r, false, false, false, false);
                }
                int channelCount = AudioUtil.GetChannelCount(target);
                AudioClipInspector.m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
                float num = AudioClipInspector.m_wantedRect.width / target.length;
                if (!AudioUtil.HasPreview(target) && (AudioUtil.IsTrackerFile(target) ? 1 : (AudioUtil.IsMovieAudio(target) ? 1 : 0)) != 0)
                {
                    float y = (double)r.height <= 150.0 ? (float)((double)r.y + (double)r.height / 2.0 - 25.0) : (float)((double)r.y + (double)r.height / 2.0 - 10.0);
                    if ((double)r.width > 64.0)
                    {
                        if (AudioUtil.IsTrackerFile(target))
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), string.Format("Module file with " + (object)AudioUtil.GetMusicChannelCount(target) + " channels."));
                        }
                        else if (AudioUtil.IsMovieAudio(target))
                        {
                            if ((double)r.width > 450.0)
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie.");
                            }
                            else
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie.");
                                EditorGUI.DropShadowLabel(new Rect(r.x, y + 10f, r.width, 20f), "To audition the sound, play the movie.");
                            }
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Can not show PCM data for this file");
                        }
                    }
                    if ((UnityEngine.Object) this.m_PlayingClip == (UnityEngine.Object)target)
                    {
                        TimeSpan timeSpan = new TimeSpan(0, 0, 0, 0, (int)((double)AudioUtil.GetClipPosition(target) * 1000.0));
                        EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds));
                    }
                }
                else
                {
                    PreviewGUI.BeginScrollView(AudioClipInspector.m_wantedRect, this.m_Position, AudioClipInspector.m_wantedRect, (GUIStyle)"PreHorizontalScrollbar", (GUIStyle)"PreHorizontalScrollbarThumb");
                    if (Event.current.type == EventType.Repaint)
                    {
                        this.DoRenderPreview(target, AudioUtil.GetImporterFromClip(target), AudioClipInspector.m_wantedRect, 1f);
                    }
                    for (int index = 0; index < channelCount; ++index)
                    {
                        if (channelCount > 1 && (double)r.width > 64.0)
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x + 5f, AudioClipInspector.m_wantedRect.y + AudioClipInspector.m_wantedRect.height / (float)channelCount * (float)index, 30f, 20f), "ch " + (index + 1).ToString());
                        }
                    }
                    if ((UnityEngine.Object) this.m_PlayingClip == (UnityEngine.Object)target)
                    {
                        float    clipPosition = AudioUtil.GetClipPosition(target);
                        TimeSpan timeSpan     = new TimeSpan(0, 0, 0, 0, (int)((double)clipPosition * 1000.0));
                        GUI.DrawTexture(new Rect(AudioClipInspector.m_wantedRect.x + (float)(int)((double)num * (double)clipPosition), AudioClipInspector.m_wantedRect.y, 2f, AudioClipInspector.m_wantedRect.height), (Texture)EditorGUIUtility.whiteTexture);
                        if ((double)r.width > 64.0)
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", (object)timeSpan.Minutes, (object)timeSpan.Seconds, (object)timeSpan.Milliseconds));
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", (object)timeSpan.Minutes, (object)timeSpan.Seconds));
                        }
                        if (!AudioUtil.IsClipPlaying(target))
                        {
                            this.m_PlayingClip = (AudioClip)null;
                        }
                    }
                    PreviewGUI.EndScrollView();
                }
                if (AudioClipInspector.m_bPlayFirst)
                {
                    AudioUtil.PlayClip(target, 0, AudioClipInspector.m_bLoop);
                    this.m_PlayingClip = target;
                    AudioClipInspector.m_bPlayFirst = false;
                }
                if (!this.playing)
                {
                    return;
                }
                GUIView.current.Repaint();
            }
        }
 public void OnDisable()
 {
     AudioUtil.StopAllClips();
     EditorPrefs.SetBool("AutoPlayAudio", AudioClipInspector.m_bAutoPlay);
 }
Exemple #12
0
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out float height)
        {
            height = -1;

            // Don't use optimizedGUI for audio filters
            var behaviour = target as MonoBehaviour;

            if (behaviour != null && AudioUtil.HasAudioCallback(behaviour) && AudioUtil.GetCustomFilterChannelCount(behaviour) > 0)
            {
                return(false);
            }

            if (ObjectIsMonoBehaviourOrScriptableObject(target))
            {
                return(false);
            }

            if (isDirty)
            {
                ResetOptimizedBlock();
            }

            if (!isVisible)
            {
                height = 0;
                return(true);
            }

            // Return cached result if any.
            if (m_OptimizedBlockState != OptimizedBlockState.CheckOptimizedBlock)
            {
                if (m_OptimizedBlockState == OptimizedBlockState.NoOptimizedBlock)
                {
                    return(false);
                }
                height = m_LastHeight;
                return(true);
            }

            // Update serialized object representation
            if (m_SerializedObject == null)
            {
                m_SerializedObject = new SerializedObject(targets, m_Context)
                {
                    inspectorMode = inspectorMode
                }
            }
            ;
            else
            {
                m_SerializedObject.Update();
                m_SerializedObject.inspectorMode = inspectorMode;
            }

            height = 0;
            SerializedProperty property = m_SerializedObject.GetIterator();
            bool childrenAreExpanded    = true;

            while (property.NextVisible(childrenAreExpanded))
            {
                var handler = ScriptAttributeUtility.GetHandler(property);
                height += handler.GetHeight(property, null, false) + EditorGUI.kControlVerticalSpacing;

                childrenAreExpanded = property.isExpanded && EditorGUI.HasVisibleChildFields(property);
            }

            m_LastHeight          = height;
            m_OptimizedBlockState = OptimizedBlockState.HasOptimizedBlock;

            return(true);
        }
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            EditorGUILayout.PropertyField(this.m_Volume, AudioManagerInspector.Styles.Volume, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_RolloffScale, AudioManagerInspector.Styles.RolloffScale, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_DopplerFactor, AudioManagerInspector.Styles.DopplerFactor, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_DefaultSpeakerMode, AudioManagerInspector.Styles.DefaultSpeakerMode, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_SampleRate, AudioManagerInspector.Styles.SampleRate, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_DSPBufferSize, AudioManagerInspector.Styles.DSPBufferSize, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_VirtualVoiceCount, AudioManagerInspector.Styles.VirtualVoiceCount, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_RealVoiceCount, AudioManagerInspector.Styles.RealVoiceCount, new GUILayoutOption[0]);
            List <string> list = new List <string>(AudioUtil.GetSpatializerPluginNames());

            list.Insert(0, "None");
            string[]          array = list.ToArray();
            List <GUIContent> list2 = new List <GUIContent>();

            string[] array2 = array;
            for (int i = 0; i < array2.Length; i++)
            {
                string text = array2[i];
                list2.Add(new GUIContent(text));
            }
            List <string> list3 = new List <string>(AudioUtil.GetAmbisonicDecoderPluginNames());

            list3.Insert(0, "None");
            string[]          array3 = list3.ToArray();
            List <GUIContent> list4  = new List <GUIContent>();

            string[] array4 = array3;
            for (int j = 0; j < array4.Length; j++)
            {
                string text2 = array4[j];
                list4.Add(new GUIContent(text2));
            }
            EditorGUI.BeginChangeCheck();
            int num = this.FindPluginStringIndex(array, this.m_SpatializerPlugin.stringValue);

            num = EditorGUILayout.Popup(AudioManagerInspector.Styles.SpatializerPlugin, num, list2.ToArray(), new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                if (num == 0)
                {
                    this.m_SpatializerPlugin.stringValue = "";
                }
                else
                {
                    this.m_SpatializerPlugin.stringValue = array[num];
                }
            }
            EditorGUI.BeginChangeCheck();
            num = this.FindPluginStringIndex(array3, this.m_AmbisonicDecoderPlugin.stringValue);
            num = EditorGUILayout.Popup(AudioManagerInspector.Styles.AmbisonicDecoderPlugin, num, list4.ToArray(), new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                if (num == 0)
                {
                    this.m_AmbisonicDecoderPlugin.stringValue = "";
                }
                else
                {
                    this.m_AmbisonicDecoderPlugin.stringValue = array3[num];
                }
            }
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_DisableAudio, AudioManagerInspector.Styles.DisableAudio, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_VirtualizeEffects, AudioManagerInspector.Styles.VirtualizeEffects, new GUILayoutOption[0]);
            base.serializedObject.ApplyModifiedProperties();
        }
Exemple #14
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }

            AudioClip clip = target as AudioClip;

            Event evt = Event.current;

            if (evt.type != EventType.Repaint && evt.type != EventType.Layout && evt.type != EventType.Used)
            {
                int px2sample = (AudioUtil.GetSampleCount(clip) / (int)r.width);

                switch (evt.type)
                {
                case EventType.MouseDrag:
                case EventType.MouseDown:
                {
                    if (r.Contains(evt.mousePosition) && !AudioUtil.IsMovieAudio(clip))
                    {
                        if (m_PlayingClip != clip || !AudioUtil.IsClipPlaying(clip))
                        {
                            AudioUtil.StopAllClips();
                            AudioUtil.PlayClip(clip, 0, m_bLoop);
                            m_PlayingClip      = clip;
                            m_PlayingInspector = this;
                        }
                        AudioUtil.SetClipSamplePosition(clip, px2sample * (int)evt.mousePosition.x);
                        evt.Use();
                    }
                }
                break;
                }
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            int c = AudioUtil.GetChannelCount(clip);

            m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
            float sec2px = ((float)m_wantedRect.width / clip.length);

            bool previewAble = AudioUtil.HasPreview(clip) || !(AudioUtil.IsTrackerFile(clip) || AudioUtil.IsMovieAudio(clip));

            if (!previewAble)
            {
                float labelY = (r.height > 150) ? r.y + (r.height / 2) - 10 :  r.y + (r.height / 2) - 25;
                if (r.width > 64)
                {
                    if (AudioUtil.IsTrackerFile(clip))
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(clip) + " channels."));
                    }
                    else if (AudioUtil.IsMovieAudio(clip))
                    {
                        if (r.width > 450)
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Audio is attached to a movie. To audition the sound, play the movie.");
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Audio is attached to a movie.");
                            EditorGUI.DropShadowLabel(new Rect(r.x, labelY + 10, r.width, 20), "To audition the sound, play the movie.");
                        }
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Can not show PCM data for this file");
                    }
                }

                if (m_PlayingInspector == this && m_PlayingClip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("Playing - {0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                }
            }
            else
            {
                PreviewGUI.BeginScrollView(m_wantedRect, m_Position, m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

                if (Event.current.type == EventType.Repaint)
                {
                    DoRenderPreview(clip, AudioUtil.GetImporterFromClip(clip), m_wantedRect, 1.0f);
                }

                for (int i = 0; i < c; ++i)
                {
                    if (c > 1 && r.width > 64)
                    {
                        var labelRect = new Rect(m_wantedRect.x + 5, m_wantedRect.y + (m_wantedRect.height / c) * i, 30, 20);
                        EditorGUI.DropShadowLabel(labelRect, "ch " + (i + 1).ToString());
                    }
                }

                if (m_PlayingInspector == this && m_PlayingClip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    GUI.DrawTexture(new Rect(m_wantedRect.x + (int)(sec2px * t), m_wantedRect.y, 2, m_wantedRect.height), EditorGUIUtility.whiteTexture);
                    if (r.width > 64)
                    {
                        EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20), string.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds));
                    }
                }


                PreviewGUI.EndScrollView();
            }


            // autoplay start?
            if (m_bAutoPlay && m_PlayingClip != clip && m_PlayingInspector == this)
            {
                AudioUtil.StopAllClips();
                AudioUtil.PlayClip(clip, 0, m_bLoop);
                m_PlayingClip      = clip;
                m_PlayingInspector = this;
            }

            // force update GUI
            if (playing)
            {
                GUIView.current.Repaint();
            }
        }
        private void DoRenderPreview(AudioClip clip, AudioImporter audioImporter, Rect wantedRect, float scaleFactor)
        {
            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AudioClipInspector.\u003CDoRenderPreview\u003Ec__AnonStorey84 previewCAnonStorey84 = new AudioClipInspector.\u003CDoRenderPreview\u003Ec__AnonStorey84();
            // ISSUE: reference to a compiler-generated field
            previewCAnonStorey84.scaleFactor = scaleFactor;
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            previewCAnonStorey84.scaleFactor = previewCAnonStorey84.scaleFactor * 0.95f;
            // ISSUE: reference to a compiler-generated field
            previewCAnonStorey84.minMaxData = !((UnityEngine.Object)audioImporter == (UnityEngine.Object)null) ? AudioUtil.GetMinMaxData(audioImporter) : (float[])null;
            // ISSUE: reference to a compiler-generated field
            previewCAnonStorey84.numChannels = clip.channels;
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            previewCAnonStorey84.numSamples = previewCAnonStorey84.minMaxData != null ? previewCAnonStorey84.minMaxData.Length / (2 * previewCAnonStorey84.numChannels) : 0;
            // ISSUE: reference to a compiler-generated field
            float height = wantedRect.height / (float)previewCAnonStorey84.numChannels;

            // ISSUE: object of a compiler-generated type is created
            // ISSUE: variable of a compiler-generated type
            AudioClipInspector.\u003CDoRenderPreview\u003Ec__AnonStorey85 previewCAnonStorey85 = new AudioClipInspector.\u003CDoRenderPreview\u003Ec__AnonStorey85();
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            // ISSUE: reference to a compiler-generated field
            for (previewCAnonStorey85.channel = 0; previewCAnonStorey85.channel < previewCAnonStorey84.numChannels; previewCAnonStorey85.channel = previewCAnonStorey85.channel + 1)
            {
                // ISSUE: object of a compiler-generated type is created
                // ISSUE: variable of a compiler-generated type
                AudioClipInspector.\u003CDoRenderPreview\u003Ec__AnonStorey83 previewCAnonStorey83 = new AudioClipInspector.\u003CDoRenderPreview\u003Ec__AnonStorey83();
                // ISSUE: reference to a compiler-generated field
                previewCAnonStorey83.\u003C\u003Ef__ref\u0024132 = previewCAnonStorey84;
                // ISSUE: reference to a compiler-generated field
                previewCAnonStorey83.\u003C\u003Ef__ref\u0024133 = previewCAnonStorey85;
                // ISSUE: reference to a compiler-generated field
                Rect r = new Rect(wantedRect.x, wantedRect.y + height * (float)previewCAnonStorey85.channel, wantedRect.width, height);
                // ISSUE: reference to a compiler-generated field
                previewCAnonStorey83.curveColor = new Color(1f, 0.5490196f, 0.0f, 1f);
                // ISSUE: reference to a compiler-generated method
                AudioCurveRendering.DrawMinMaxFilledCurve(r, new AudioCurveRendering.AudioMinMaxCurveAndColorEvaluator(previewCAnonStorey83.\u003C\u003Em__143));
            }
        }
        public override void OnPreviewSettings()
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }

            AudioClip clip = target as AudioClip;

            bool isEditingMultipleObjects = targets.Length > 1;

            using (new EditorGUI.DisabledScope(AudioUtil.IsMovieAudio(clip)))
            {
                bool oldAutoPlay = m_bAutoPlay;
                bool newAutoPlay = PreviewGUI.CycleButton(oldAutoPlay ? 1 : 0, s_AutoPlayIcons) != 0;
                if (oldAutoPlay != newAutoPlay)
                {
                    m_bAutoPlay = newAutoPlay;
                    InspectorWindow.RepaintAllInspectors();
                }

                bool oldLoop = m_bLoop;
                bool newLoop = PreviewGUI.CycleButton(oldLoop ? 1 : 0, s_LoopIcons) != 0;
                if (oldLoop != newLoop)
                {
                    m_bLoop = newLoop;
                    if (playing)
                    {
                        AudioUtil.LoopClip(clip, newLoop);
                    }
                    InspectorWindow.RepaintAllInspectors();
                }

                using (new EditorGUI.DisabledScope(isEditingMultipleObjects && !playing && m_PlayingInspector != this))
                {
                    bool curPlaying = m_PlayingInspector == this && playing;
                    bool newPlaying = PreviewGUI.CycleButton(curPlaying ? 1 : 0, s_PlayIcons) != 0;

                    if (newPlaying != curPlaying)
                    {
                        AudioUtil.StopAllClips();
                        m_PlayingClip      = null;
                        m_PlayingInspector = null;

                        if (newPlaying && !isEditingMultipleObjects)
                        {
                            AudioUtil.PlayClip(clip, 0, m_bLoop);
                            m_PlayingClip      = clip;
                            m_PlayingInspector = this;
                        }
                    }
                }
            }

            // autoplay start?
            if (m_bAutoPlay && m_PlayingClip != clip && m_PlayingInspector == this && !isEditingMultipleObjects)
            {
                AudioUtil.StopAllClips();
                m_PlayingClip      = null;
                m_PlayingInspector = null;

                if (!isEditingMultipleObjects)
                {
                    AudioUtil.PlayClip(clip, 0, m_bLoop);
                    m_PlayingClip      = clip;
                    m_PlayingInspector = this;
                }
            }
        }
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            bool flag = base.GetOptimizedGUIBlockImplementation(isDirty, isVisible, out block, out height);

            if ((base.target is MonoBehaviour) && (AudioUtil.HaveAudioCallback(base.target as MonoBehaviour) && (AudioUtil.GetCustomFilterChannelCount(base.target as MonoBehaviour) > 0)))
            {
                return(false);
            }
            if (this.IsMissingMonoBehaviourTarget())
            {
                return(false);
            }
            return(flag);
        }
 public void OnDisable()
 {
     AudioUtil.StopAllClips();
     AudioUtil.ClearWaveForm(this.target as AudioClip);
     EditorPrefs.SetBool("AutoPlayAudio", AudioClipInspector.m_bAutoPlay);
 }
 public override void ReloadPreviewInstances()
 {
     AudioUtil.ClearWaveForm(this.target as AudioClip);
 }
Exemple #20
0
        private void Audio3DGUI()
        {
            EditorGUILayout.Slider(this.m_DopplerLevel, 0f, 5f, AudioSourceInspector.ms_Styles.dopplerLevelLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUI.BeginChangeCheck();
            if (this.m_RolloffMode.hasMultipleDifferentValues || (this.m_RolloffMode.enumValueIndex == 2 && this.m_AudioCurves[0].curveProp.hasMultipleDifferentValues))
            {
                EditorGUILayout.TargetChoiceField(this.m_AudioCurves[0].curveProp, AudioSourceInspector.ms_Styles.rolloffLabel, new TargetChoiceHandler.TargetChoiceMenuFunction(AudioSourceInspector.SetRolloffToTarget), new GUILayoutOption[0]);
            }
            else
            {
                EditorGUILayout.PropertyField(this.m_RolloffMode, AudioSourceInspector.ms_Styles.rolloffLabel, new GUILayoutOption[0]);
                EditorGUI.indentLevel++;
                if (this.m_RolloffMode.enumValueIndex != 2)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(this.m_MinDistance, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_MinDistance.floatValue = Mathf.Clamp(this.m_MinDistance.floatValue, 0f, this.m_MaxDistance.floatValue / 1.01f);
                    }
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.LabelField(this.m_MinDistance.displayName, AudioSourceInspector.ms_Styles.controlledByCurveLabel, new GUILayoutOption[0]);
                    EditorGUI.EndDisabledGroup();
                }
                EditorGUI.indentLevel--;
            }
            AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spreadLabel, this.m_AudioCurves[2].curveProp, 0f, 360f, true);
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_MaxDistance, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_MaxDistance.floatValue = Mathf.Min(Mathf.Max(Mathf.Max(this.m_MaxDistance.floatValue, 0.01f), this.m_MinDistance.floatValue * 1.01f), 1000000f);
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.m_RefreshCurveEditor = true;
            }
            Rect aspectRect = GUILayoutUtility.GetAspectRect(1.333f, GUI.skin.textField);

            aspectRect.xMin += EditorGUI.indent;
            if (Event.current.type != EventType.Layout && Event.current.type != EventType.Used)
            {
                this.m_CurveEditor.rect = new Rect(aspectRect.x, aspectRect.y, aspectRect.width, aspectRect.height);
            }
            this.UpdateWrappersAndLegend();
            GUI.Label(this.m_CurveEditor.drawRect, GUIContent.none, "TextField");
            this.m_CurveEditor.hRangeLocked = Event.current.shift;
            this.m_CurveEditor.vRangeLocked = EditorGUI.actionKey;
            this.m_CurveEditor.OnGUI();
            if (base.targets.Length == 1)
            {
                AudioSource   audioSource = (AudioSource)this.target;
                AudioListener x           = (AudioListener)UnityEngine.Object.FindObjectOfType(typeof(AudioListener));
                if (x != null)
                {
                    float magnitude = (AudioUtil.GetListenerPos() - audioSource.transform.position).magnitude;
                    this.DrawLabel("Listener", magnitude, aspectRect);
                }
            }
            this.DrawLegend();
            AudioSourceInspector.AudioCurveWrapper[] audioCurves = this.m_AudioCurves;
            for (int i = 0; i < audioCurves.Length; i++)
            {
                AudioSourceInspector.AudioCurveWrapper audioCurveWrapper = audioCurves[i];
                if (this.m_CurveEditor.getCurveWrapperById(audioCurveWrapper.id) != null && this.m_CurveEditor.getCurveWrapperById(audioCurveWrapper.id).changed)
                {
                    AnimationCurve curve = this.m_CurveEditor.getCurveWrapperById(audioCurveWrapper.id).curve;
                    if (curve.length > 0)
                    {
                        audioCurveWrapper.curveProp.animationCurveValue = curve;
                        this.m_CurveEditor.getCurveWrapperById(audioCurveWrapper.id).changed = false;
                        if (audioCurveWrapper.type == AudioSourceInspector.AudioCurveType.Volume)
                        {
                            this.m_RolloffMode.enumValueIndex = 2;
                        }
                        if (audioCurveWrapper.type == AudioSourceInspector.AudioCurveType.Lowpass && audioCurveWrapper.curveProp.animationCurveValue.length == 1)
                        {
                            Keyframe keyframe = audioCurveWrapper.curveProp.animationCurveValue.keys[0];
                            this.m_CutoffFrequency.floatValue = (1f - keyframe.value) * 22000f;
                        }
                    }
                }
            }
        }
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            bool optimizedGUIBlockImplementation = base.GetOptimizedGUIBlockImplementation(isDirty, isVisible, out block, out height);

            return((!(this.target is MonoBehaviour) || !AudioUtil.HaveAudioCallback(this.target as MonoBehaviour) || AudioUtil.GetCustomFilterChannelCount(this.target as MonoBehaviour) <= 0) && !this.IsMissingMonoBehaviourTarget() && optimizedGUIBlockImplementation);
        }
Exemple #22
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }
            AudioClip target  = this.target as AudioClip;
            Event     current = Event.current;

            if (((current.type == EventType.Repaint) || (current.type == EventType.Layout)) || (current.type == EventType.Used))
            {
                if (Event.current.type == EventType.Repaint)
                {
                    background.Draw(r, false, false, false, false);
                }
                int channelCount = AudioUtil.GetChannelCount(target);
                m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
                float num3 = m_wantedRect.width / target.length;
                if (!AudioUtil.HasPreview(target) && (AudioUtil.IsTrackerFile(target) || AudioUtil.IsMovieAudio(target)))
                {
                    float y = (r.height <= 150f) ? ((r.y + (r.height / 2f)) - 25f) : ((r.y + (r.height / 2f)) - 10f);
                    if (r.width > 64f)
                    {
                        if (AudioUtil.IsTrackerFile(target))
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(target) + " channels.", new object[0]));
                        }
                        else if (AudioUtil.IsMovieAudio(target))
                        {
                            if (r.width > 450f)
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie.");
                            }
                            else
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Audio is attached to a movie.");
                                EditorGUI.DropShadowLabel(new Rect(r.x, y + 10f, r.width, 20f), "To audition the sound, play the movie.");
                            }
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, y, r.width, 20f), "Can not show PCM data for this file");
                        }
                    }
                    if (this.m_PlayingClip == target)
                    {
                        float    clipPosition = AudioUtil.GetClipPosition(target);
                        TimeSpan span         = new TimeSpan(0, 0, 0, 0, (int)(clipPosition * 1000f));
                        EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", span.Minutes, span.Seconds, span.Milliseconds));
                    }
                }
                else
                {
                    PreviewGUI.BeginScrollView(m_wantedRect, this.m_Position, m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    Texture2D image = null;
                    if (r.width < 100f)
                    {
                        image = AssetPreview.GetAssetPreview(target);
                    }
                    else
                    {
                        image = AudioUtil.GetWaveFormFast(target, 1, 0, target.samples, r.width, r.height);
                    }
                    if (image == null)
                    {
                        Rect position = new Rect {
                            x      = ((m_wantedRect.width - s_DefaultIcon.width) / 2f) + m_wantedRect.x,
                            y      = ((m_wantedRect.height - s_DefaultIcon.height) / 2f) + m_wantedRect.y,
                            width  = s_DefaultIcon.width,
                            height = s_DefaultIcon.height
                        };
                        GUI.DrawTexture(position, s_DefaultIcon);
                        base.Repaint();
                    }
                    else
                    {
                        GUI.DrawTexture(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, m_wantedRect.height), image);
                    }
                    for (int i = 0; i < channelCount; i++)
                    {
                        if ((channelCount > 1) && (r.width > 64f))
                        {
                            Rect rect2 = new Rect(m_wantedRect.x + 5f, m_wantedRect.y + ((m_wantedRect.height / ((float)channelCount)) * i), 30f, 20f);
                            EditorGUI.DropShadowLabel(rect2, "ch " + ((i + 1)).ToString());
                        }
                    }
                    if (this.m_PlayingClip == target)
                    {
                        float    num7  = AudioUtil.GetClipPosition(target);
                        TimeSpan span2 = new TimeSpan(0, 0, 0, 0, (int)(num7 * 1000f));
                        GUI.DrawTexture(new Rect(m_wantedRect.x + ((int)(num3 * num7)), m_wantedRect.y, 2f, m_wantedRect.height), EditorGUIUtility.whiteTexture);
                        if (r.width > 64f)
                        {
                            EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", span2.Minutes, span2.Seconds, span2.Milliseconds));
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(m_wantedRect.x, m_wantedRect.y, m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", span2.Minutes, span2.Seconds));
                        }
                        if (!AudioUtil.IsClipPlaying(target))
                        {
                            this.m_PlayingClip = null;
                        }
                    }
                    PreviewGUI.EndScrollView();
                }
                if (m_bPlayFirst)
                {
                    AudioUtil.PlayClip(target, 0, m_bLoop);
                    this.m_PlayingClip = target;
                    m_bPlayFirst       = false;
                }
                if (this.playing)
                {
                    GUIView.current.Repaint();
                }
            }
            else
            {
                int num = AudioUtil.GetSampleCount(target) / ((int)r.width);
                switch (current.type)
                {
                case EventType.MouseDown:
                case EventType.MouseDrag:
                    if (r.Contains(current.mousePosition) && !AudioUtil.IsMovieAudio(target))
                    {
                        if (this.m_PlayingClip != target)
                        {
                            AudioUtil.StopAllClips();
                            AudioUtil.PlayClip(target, 0, m_bLoop);
                            this.m_PlayingClip = target;
                        }
                        AudioUtil.SetClipSamplePosition(target, num * ((int)current.mousePosition.x));
                        current.Use();
                    }
                    break;
                }
            }
        }
Exemple #23
0
        public static void PlayClip(AudioClip clip, int startSample)
        {
            bool loop = false;

            AudioUtil.PlayClip(clip, startSample, loop);
        }
        internal override bool GetOptimizedGUIBlock(bool isDirty, bool isVisible, out OptimizedGUIBlock block, out float height)
        {
            block = null; height = -1;

            // Don't use optimizedGUI for audio filters
            var behaviour = target as MonoBehaviour;

            if (behaviour != null && AudioUtil.HasAudioCallback(behaviour) && AudioUtil.GetCustomFilterChannelCount(behaviour) > 0)
            {
                return(false);
            }

            if (IsMissingMonoBehaviourTarget())
            {
                return(false);
            }

            if (isDirty && m_OptimizedBlock != null)
            {
                ResetOptimizedBlock();
            }

            if (!isVisible)
            {
                if (m_OptimizedBlock == null)
                {
                    m_OptimizedBlock = new OptimizedGUIBlock();
                }

                height = 0;
                block  = m_OptimizedBlock;
                return(true);
            }

            // Return cached result if any.
            if (m_OptimizedBlockState != OptimizedBlockState.CheckOptimizedBlock)
            {
                if (m_OptimizedBlockState == OptimizedBlockState.NoOptimizedBlock)
                {
                    return(false);
                }
                height = m_LastHeight;
                block  = m_LastOptimizedBlock;
                return(true);
            }

            // Update serialized object representation
            if (m_SerializedObject == null)
            {
                m_SerializedObject = new SerializedObject(targets, m_Context)
                {
                    inspectorMode = m_InspectorMode
                }
            }
            ;
            else
            {
                m_SerializedObject.Update();
                m_SerializedObject.inspectorMode = m_InspectorMode;
            }

            height = 0;
            SerializedProperty property = m_SerializedObject.GetIterator();

            while (property.NextVisible(height <= 0))
            {
                var handler = ScriptAttributeUtility.GetHandler(property);
                if (!handler.CanCacheInspectorGUI(property))
                {
                    return(ResetOptimizedBlock(OptimizedBlockState.NoOptimizedBlock));
                }

                // Allocate height for control plus spacing below it
                height += handler.GetHeight(property, null, true) + EditorGUI.kControlVerticalSpacing;
            }

            // Allocate height for spacing above first control
            if (height > 0)
            {
                height += EditorGUI.kControlVerticalSpacing;
            }

            if (m_OptimizedBlock == null)
            {
                m_OptimizedBlock = new OptimizedGUIBlock();
            }

            m_LastHeight          = height;
            m_LastOptimizedBlock  = block = m_OptimizedBlock;
            m_OptimizedBlockState = OptimizedBlockState.HasOptimizedBlock;
            return(true);
        }
Exemple #25
0
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (s_DefaultIcon == null)
            {
                Init();
            }

            AudioClip clip = target as AudioClip;

            Event evt = Event.current;

            if (evt.type != EventType.Repaint && evt.type != EventType.Layout && evt.type != EventType.Used)
            {
                switch (evt.type)
                {
                case EventType.MouseDrag:
                case EventType.MouseDown:
                {
                    if (r.Contains(evt.mousePosition))
                    {
                        var startSample = (int)(evt.mousePosition.x * (AudioUtil.GetSampleCount(clip) / (int)r.width));
                        if (!AudioUtil.IsClipPlaying(clip) || clip != m_Clip)
                        {
                            PlayClip(clip, startSample, s_Loop);
                        }
                        else
                        {
                            AudioUtil.SetClipSamplePosition(clip, startSample);
                        }
                        evt.Use();
                    }
                }
                break;
                }
                return;
            }

            if (Event.current.type == EventType.Repaint)
            {
                background.Draw(r, false, false, false, false);
            }

            int c = AudioUtil.GetChannelCount(clip);

            s_WantedRect = new Rect(r.x, r.y, r.width, r.height);
            float sec2px = ((float)s_WantedRect.width / clip.length);

            bool previewAble = AudioUtil.HasPreview(clip) || !(AudioUtil.IsTrackerFile(clip));

            if (!previewAble)
            {
                float labelY = (r.height > 150) ? r.y + (r.height / 2) - 10 :  r.y + (r.height / 2) - 25;
                if (r.width > 64)
                {
                    if (AudioUtil.IsTrackerFile(clip))
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(clip) + " channels."));
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(r.x, labelY, r.width, 20), "Can not show PCM data for this file");
                    }
                }

                if (m_Clip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("Playing - {0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                }
            }
            else
            {
                PreviewGUI.BeginScrollView(s_WantedRect, m_Position, s_WantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");

                if (Event.current.type == EventType.Repaint)
                {
                    DoRenderPreview(true, clip, AudioUtil.GetImporterFromClip(clip), s_WantedRect, 1.0f);
                }

                for (int i = 0; i < c; ++i)
                {
                    if (c > 1 && r.width > 64)
                    {
                        var labelRect = new Rect(s_WantedRect.x + 5, s_WantedRect.y + (s_WantedRect.height / c) * i, 30, 20);
                        EditorGUI.DropShadowLabel(labelRect, "ch " + (i + 1).ToString());
                    }
                }

                if (m_Clip == clip)
                {
                    float t = AudioUtil.GetClipPosition(clip);

                    System.TimeSpan ts = new System.TimeSpan(0, 0, 0, 0, (int)(t * 1000.0f));

                    GUI.DrawTexture(new Rect(s_WantedRect.x + (int)(sec2px * t), s_WantedRect.y, 2, s_WantedRect.height), EditorGUIUtility.whiteTexture);
                    if (r.width > 64)
                    {
                        EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("{0:00}:{1:00}.{2:000}", ts.Minutes, ts.Seconds, ts.Milliseconds));
                    }
                    else
                    {
                        EditorGUI.DropShadowLabel(new Rect(s_WantedRect.x, s_WantedRect.y, s_WantedRect.width, 20), string.Format("{0:00}:{1:00}", ts.Minutes, ts.Seconds));
                    }
                }

                PreviewGUI.EndScrollView();
            }


            if (!m_MultiEditing && (s_PlayFirst || (s_AutoPlay && m_Clip != clip)))
            {
                // Autoplay preview
                PlayClip(clip, 0, s_Loop);
                s_PlayFirst = false;
            }

            // force update GUI
            if (playing)
            {
                GUIView.current.Repaint();
            }
        }
        public override void OnPreviewGUI(Rect r, GUIStyle background)
        {
            if (AudioClipInspector.s_DefaultIcon == null)
            {
                AudioClipInspector.Init();
            }
            AudioClip audioClip = base.target as AudioClip;
            Event     current   = Event.current;

            if (current.type != EventType.Repaint && current.type != EventType.Layout && current.type != EventType.Used)
            {
                int       num  = AudioUtil.GetSampleCount(audioClip) / (int)r.width;
                EventType type = current.type;
                if (type == EventType.MouseDrag || type == EventType.MouseDown)
                {
                    if (r.Contains(current.mousePosition) && !AudioUtil.IsMovieAudio(audioClip))
                    {
                        if (this.m_PlayingClip != audioClip)
                        {
                            AudioUtil.StopAllClips();
                            AudioUtil.PlayClip(audioClip, 0, AudioClipInspector.m_bLoop);
                            this.m_PlayingClip = audioClip;
                        }
                        AudioUtil.SetClipSamplePosition(audioClip, num * (int)current.mousePosition.x);
                        current.Use();
                    }
                }
            }
            else
            {
                if (Event.current.type == EventType.Repaint)
                {
                    background.Draw(r, false, false, false, false);
                }
                int channelCount = AudioUtil.GetChannelCount(audioClip);
                AudioClipInspector.m_wantedRect = new Rect(r.x, r.y, r.width, r.height);
                float num2 = AudioClipInspector.m_wantedRect.width / audioClip.length;
                if (!AudioUtil.HasPreview(audioClip) && (AudioUtil.IsTrackerFile(audioClip) || AudioUtil.IsMovieAudio(audioClip)))
                {
                    float num3 = (r.height <= 150f) ? (r.y + r.height / 2f - 25f) : (r.y + r.height / 2f - 10f);
                    if (r.width > 64f)
                    {
                        if (AudioUtil.IsTrackerFile(audioClip))
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), string.Format("Module file with " + AudioUtil.GetMusicChannelCount(audioClip) + " channels.", new object[0]));
                        }
                        else if (AudioUtil.IsMovieAudio(audioClip))
                        {
                            if (r.width > 450f)
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Audio is attached to a movie. To audition the sound, play the movie.");
                            }
                            else
                            {
                                EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Audio is attached to a movie.");
                                EditorGUI.DropShadowLabel(new Rect(r.x, num3 + 10f, r.width, 20f), "To audition the sound, play the movie.");
                            }
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(r.x, num3, r.width, 20f), "Can not show PCM data for this file");
                        }
                    }
                    if (this.m_PlayingClip == audioClip)
                    {
                        float    clipPosition = AudioUtil.GetClipPosition(audioClip);
                        TimeSpan timeSpan     = new TimeSpan(0, 0, 0, 0, (int)(clipPosition * 1000f));
                        EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("Playing - {0:00}:{1:00}.{2:000}", timeSpan.Minutes, timeSpan.Seconds, timeSpan.Milliseconds));
                    }
                }
                else
                {
                    PreviewGUI.BeginScrollView(AudioClipInspector.m_wantedRect, this.m_Position, AudioClipInspector.m_wantedRect, "PreHorizontalScrollbar", "PreHorizontalScrollbarThumb");
                    if (Event.current.type == EventType.Repaint)
                    {
                        this.DoRenderPreview(audioClip, AudioUtil.GetImporterFromClip(audioClip), AudioClipInspector.m_wantedRect, 1f);
                    }
                    for (int i = 0; i < channelCount; i++)
                    {
                        if (channelCount > 1 && r.width > 64f)
                        {
                            Rect position = new Rect(AudioClipInspector.m_wantedRect.x + 5f, AudioClipInspector.m_wantedRect.y + AudioClipInspector.m_wantedRect.height / (float)channelCount * (float)i, 30f, 20f);
                            EditorGUI.DropShadowLabel(position, "ch " + (i + 1).ToString());
                        }
                    }
                    if (this.m_PlayingClip == audioClip)
                    {
                        float    clipPosition2 = AudioUtil.GetClipPosition(audioClip);
                        TimeSpan timeSpan2     = new TimeSpan(0, 0, 0, 0, (int)(clipPosition2 * 1000f));
                        GUI.DrawTexture(new Rect(AudioClipInspector.m_wantedRect.x + (float)((int)(num2 * clipPosition2)), AudioClipInspector.m_wantedRect.y, 2f, AudioClipInspector.m_wantedRect.height), EditorGUIUtility.whiteTexture);
                        if (r.width > 64f)
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}.{2:000}", timeSpan2.Minutes, timeSpan2.Seconds, timeSpan2.Milliseconds));
                        }
                        else
                        {
                            EditorGUI.DropShadowLabel(new Rect(AudioClipInspector.m_wantedRect.x, AudioClipInspector.m_wantedRect.y, AudioClipInspector.m_wantedRect.width, 20f), string.Format("{0:00}:{1:00}", timeSpan2.Minutes, timeSpan2.Seconds));
                        }
                        if (!AudioUtil.IsClipPlaying(audioClip))
                        {
                            this.m_PlayingClip = null;
                        }
                    }
                    PreviewGUI.EndScrollView();
                }
                if (AudioClipInspector.m_bPlayFirst)
                {
                    AudioUtil.PlayClip(audioClip, 0, AudioClipInspector.m_bLoop);
                    this.m_PlayingClip = audioClip;
                    AudioClipInspector.m_bPlayFirst = false;
                }
                if (this.playing)
                {
                    GUIView.current.Repaint();
                }
            }
        }
Exemple #27
0
        void OnEnable()
        {
            m_AudioClip             = serializedObject.FindProperty("m_audioClip");
            m_PlayOnAwake           = serializedObject.FindProperty("m_PlayOnAwake");
            m_Volume                = serializedObject.FindProperty("m_Volume");
            m_Pitch                 = serializedObject.FindProperty("m_Pitch");
            m_Loop                  = serializedObject.FindProperty("Loop");
            m_Mute                  = serializedObject.FindProperty("Mute");
            m_Spatialize            = serializedObject.FindProperty("Spatialize");
            m_SpatializePostEffects = serializedObject.FindProperty("SpatializePostEffects");
            m_Priority              = serializedObject.FindProperty("Priority");
            m_DopplerLevel          = serializedObject.FindProperty("DopplerLevel");
            m_MinDistance           = serializedObject.FindProperty("MinDistance");
            m_MaxDistance           = serializedObject.FindProperty("MaxDistance");
            m_Pan2D                 = serializedObject.FindProperty("Pan2D");
            m_RolloffMode           = serializedObject.FindProperty("rolloffMode");
            m_BypassEffects         = serializedObject.FindProperty("BypassEffects");
            m_BypassListenerEffects = serializedObject.FindProperty("BypassListenerEffects");
            m_BypassReverbZones     = serializedObject.FindProperty("BypassReverbZones");
            m_OutputAudioMixerGroup = serializedObject.FindProperty("OutputAudioMixerGroup");

            m_AudioCurves = new AudioCurveWrapper[]
            {
                new AudioCurveWrapper(AudioCurveType.Volume, "Volume", kRolloffCurveID, kRolloffCurveColor, serializedObject.FindProperty("rolloffCustomCurve"), 0, 1),
                new AudioCurveWrapper(AudioCurveType.SpatialBlend, "Spatial Blend", kSpatialBlendCurveID, kSpatialCurveColor, serializedObject.FindProperty("panLevelCustomCurve"), 0, 1),
                new AudioCurveWrapper(AudioCurveType.Spread, "Spread", kSpreadCurveID, kSpreadCurveColor, serializedObject.FindProperty("spreadCustomCurve"), 0, 1),
                new AudioCurveWrapper(AudioCurveType.Lowpass, "Low-Pass", kLowPassCurveID, kLowPassCurveColor, null, 0, 1),
                new AudioCurveWrapper(AudioCurveType.ReverbZoneMix, "Reverb Zone Mix", kReverbZoneMixCurveID, kReverbZoneMixCurveColor, serializedObject.FindProperty("reverbZoneMixCustomCurve"), 0, 1.1f)
            };

            m_CurveEditorSettings.hRangeMin = 0.0f;
            m_CurveEditorSettings.vRangeMin = 0.0f;
            m_CurveEditorSettings.vRangeMax = 1.1f;
            m_CurveEditorSettings.hRangeMax = 1.0f;
            m_CurveEditorSettings.vSlider   = false;
            m_CurveEditorSettings.hSlider   = false;

            TickStyle hTS = new TickStyle();

            hTS.tickColor.color = new Color(0.0f, 0.0f, 0.0f, 0.15f);
            hTS.distLabel       = 30;
            m_CurveEditorSettings.hTickStyle = hTS;
            TickStyle vTS = new TickStyle();

            vTS.tickColor.color = new Color(0.0f, 0.0f, 0.0f, 0.15f);
            vTS.distLabel       = 20;
            m_CurveEditorSettings.vTickStyle = vTS;

            m_CurveEditorSettings.undoRedoSelection = true;

            m_CurveEditor          = new CurveEditor(new Rect(0, 0, 1000, 100), new CurveWrapper[0], false);
            m_CurveEditor.settings = m_CurveEditorSettings;
            m_CurveEditor.margin   = 25;
            m_CurveEditor.SetShownHRangeInsideMargins(0.0f, 1.0f);
            m_CurveEditor.SetShownVRangeInsideMargins(0.0f, 1.1f);
            m_CurveEditor.ignoreScrollWheelUntilClicked = true;

            m_LastSourcePosition      = GetSourcePos(target);
            m_LastListenerPosition    = AudioUtil.GetListenerPos();
            EditorApplication.update += Update;

            m_Expanded3D = EditorPrefs.GetBool("AudioSourceExpanded3D", m_Expanded3D);
        }
Exemple #28
0
        private void Audio3DGUI()
        {
            EditorGUILayout.Slider(this.m_DopplerLevel, 0f, 5f, ms_Styles.dopplerLevelLabel, new GUILayoutOption[0]);
            EditorGUI.BeginChangeCheck();
            AnimProp(ms_Styles.spreadLabel, this.m_AudioCurves[2].curveProp, 0f, 360f, true);
            if (this.m_RolloffMode.hasMultipleDifferentValues || ((this.m_RolloffMode.enumValueIndex == 2) && this.m_AudioCurves[0].curveProp.hasMultipleDifferentValues))
            {
                EditorGUILayout.TargetChoiceField(this.m_AudioCurves[0].curveProp, ms_Styles.rolloffLabel, new TargetChoiceHandler.TargetChoiceMenuFunction(AudioSourceInspector.SetRolloffToTarget), new GUILayoutOption[0]);
            }
            else
            {
                EditorGUILayout.PropertyField(this.m_RolloffMode, ms_Styles.rolloffLabel, new GUILayoutOption[0]);
                if (this.m_RolloffMode.enumValueIndex != 2)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(this.m_MinDistance, new GUILayoutOption[0]);
                    if (EditorGUI.EndChangeCheck())
                    {
                        this.m_MinDistance.floatValue = Mathf.Clamp(this.m_MinDistance.floatValue, 0f, this.m_MaxDistance.floatValue / 1.01f);
                    }
                }
                else
                {
                    EditorGUI.BeginDisabledGroup(true);
                    EditorGUILayout.LabelField(this.m_MinDistance.displayName, ms_Styles.controlledByCurveLabel, new GUILayoutOption[0]);
                    EditorGUI.EndDisabledGroup();
                }
            }
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(this.m_MaxDistance, new GUILayoutOption[0]);
            if (EditorGUI.EndChangeCheck())
            {
                this.m_MaxDistance.floatValue = Mathf.Min(Mathf.Max(Mathf.Max(this.m_MaxDistance.floatValue, 0.01f), this.m_MinDistance.floatValue * 1.01f), 1000000f);
            }
            if (EditorGUI.EndChangeCheck())
            {
                this.m_RefreshCurveEditor = true;
            }
            Rect aspectRect = GUILayoutUtility.GetAspectRect(1.333f, GUI.skin.textField);

            aspectRect.xMin += EditorGUI.indent;
            if ((Event.current.type != EventType.Layout) && (Event.current.type != EventType.Used))
            {
                this.m_CurveEditor.rect = new Rect(aspectRect.x, aspectRect.y, aspectRect.width, aspectRect.height);
            }
            this.UpdateWrappersAndLegend();
            GUI.Label(this.m_CurveEditor.drawRect, GUIContent.none, "TextField");
            this.m_CurveEditor.hRangeLocked = Event.current.shift;
            this.m_CurveEditor.vRangeLocked = EditorGUI.actionKey;
            this.m_CurveEditor.OnGUI();
            if (base.targets.Length == 1)
            {
                AudioSource   target   = (AudioSource)this.target;
                AudioListener listener = (AudioListener)Object.FindObjectOfType(typeof(AudioListener));
                if (listener != null)
                {
                    Vector3 vector    = AudioUtil.GetListenerPos() - target.transform.position;
                    float   magnitude = vector.magnitude;
                    this.DrawLabel("Listener", magnitude, aspectRect);
                }
            }
            this.DrawLegend();
            foreach (AudioCurveWrapper wrapper in this.m_AudioCurves)
            {
                if ((this.m_CurveEditor.getCurveWrapperById(wrapper.id) != null) && this.m_CurveEditor.getCurveWrapperById(wrapper.id).changed)
                {
                    AnimationCurve curve = this.m_CurveEditor.getCurveWrapperById(wrapper.id).curve;
                    if (curve.length > 0)
                    {
                        wrapper.curveProp.animationCurveValue = curve;
                        this.m_CurveEditor.getCurveWrapperById(wrapper.id).changed = false;
                        if (wrapper.type == AudioCurveType.Volume)
                        {
                            this.m_RolloffMode.enumValueIndex = 2;
                        }
                    }
                }
            }
        }
Exemple #29
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);
            EditorGUILayout.PropertyField(m_VirtualizeEffects, Styles.VirtualizeEffects);

            serializedObject.ApplyModifiedProperties();
        }
Exemple #30
0
        private void Audio3DGUI()
        {
            EditorGUILayout.Slider(m_DopplerLevel, 0.0f, 5.0f, Styles.dopplerLevelLabel);

            // Spread control
            AnimProp(Styles.spreadLabel, m_AudioCurves[kSpreadCurveID].curveProp, 0.0f, 360.0f, true);

            // Rolloff mode
            if (m_RolloffMode.hasMultipleDifferentValues ||
                (m_RolloffMode.enumValueIndex == (int)AudioRolloffMode.Custom && m_AudioCurves[kRolloffCurveID].curveProp.hasMultipleDifferentValues)
                )
            {
                EditorGUILayout.TargetChoiceField(m_AudioCurves[kRolloffCurveID].curveProp, Styles.rolloffLabel, SetRolloffToTarget);
            }
            else
            {
                EditorGUILayout.PropertyField(m_RolloffMode, Styles.rolloffLabel);

                if ((AudioRolloffMode)m_RolloffMode.enumValueIndex != AudioRolloffMode.Custom)
                {
                    EditorGUI.BeginChangeCheck();
                    EditorGUILayout.PropertyField(m_MinDistance);
                    if (EditorGUI.EndChangeCheck())
                    {
                        m_MinDistance.floatValue = Mathf.Clamp(m_MinDistance.floatValue, 0, m_MaxDistance.floatValue / 1.01f);
                    }
                }
                else
                {
                    using (new EditorGUI.DisabledScope(true))
                    {
                        EditorGUILayout.LabelField(m_MinDistance.displayName, Styles.controlledByCurveLabel);
                    }
                }
            }

            // Max distance control
            EditorGUI.BeginChangeCheck();
            EditorGUILayout.PropertyField(m_MaxDistance);
            if (EditorGUI.EndChangeCheck())
            {
                m_MaxDistance.floatValue = Mathf.Min(Mathf.Max(Mathf.Max(m_MaxDistance.floatValue, 0.01f), m_MinDistance.floatValue * 1.01f), 1000000.0f);
            }

            Rect r = GUILayoutUtility.GetAspectRect(1.333f, GUI.skin.textField);

            r.xMin += EditorGUI.indent;
            if (Event.current.type != EventType.Layout && Event.current.type != EventType.Used)
            {
                m_CurveEditor.rect = new Rect(r.x, r.y, r.width, r.height);
            }

            // Draw Curve Editor
            UpdateWrappersAndLegend();
            GUI.Label(m_CurveEditor.drawRect, GUIContent.none, "TextField");

            m_CurveEditor.hRangeLocked = Event.current.shift;
            m_CurveEditor.vRangeLocked = EditorGUI.actionKey;

            m_CurveEditor.OnGUI();

            // Draw current listener position
            if (targets.Length == 1)
            {
                AudioSource   t             = (AudioSource)target;
                AudioListener audioListener = (AudioListener)FindObjectOfType(typeof(AudioListener));
                if (audioListener != null)
                {
                    float distToListener = (AudioUtil.GetListenerPos() - t.transform.position).magnitude;
                    DrawLabel("Listener", distToListener, r);
                }
            }

            // Draw legend
            DrawLegend();

            if (!m_CurveEditor.InLiveEdit())
            {
                // Check if any of the curves changed
                foreach (AudioCurveWrapper audioCurve in m_AudioCurves)
                {
                    if ((m_CurveEditor.GetCurveWrapperFromID(audioCurve.id) != null) && (m_CurveEditor.GetCurveWrapperFromID(audioCurve.id).changed))
                    {
                        AnimationCurve changedCurve = m_CurveEditor.GetCurveWrapperFromID(audioCurve.id).curve;

                        // Never save a curve with no keys
                        if (changedCurve.length > 0)
                        {
                            audioCurve.curveProp.animationCurveValue = changedCurve;
                            m_CurveEditor.GetCurveWrapperFromID(audioCurve.id).changed = false;

                            // Volume curve special handling
                            if (audioCurve.type == AudioCurveType.Volume)
                            {
                                m_RolloffMode.enumValueIndex = (int)AudioRolloffMode.Custom;
                            }
                        }
                    }
                }
            }
        }