Exemple #1
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.Update();
     AudioSourceInspector.AnimProp(new GUIContent("Cutoff Frequency"), this.m_LowpassLevelCustomCurve, 22000f, 0f, true);
     EditorGUILayout.PropertyField(this.m_LowpassResonanceQ, new GUILayoutOption[0]);
     base.serializedObject.ApplyModifiedProperties();
 }
			public AudioCurveWrapper(AudioSourceInspector.AudioCurveType type, string legend, int id, Color color, SerializedProperty curveProp, float rangeMin, float rangeMax)
			{
				this.type = type;
				this.legend = new GUIContent(legend);
				this.id = id;
				this.color = color;
				this.curveProp = curveProp;
				this.rangeMin = rangeMin;
				this.rangeMax = rangeMax;
			}
Exemple #3
0
        private CurveWrapper[] GetCurveWrapperArray()
        {
            List <CurveWrapper> list = new List <CurveWrapper>();

            AudioSourceInspector.AudioCurveWrapper[] audioCurves = this.m_AudioCurves;
            for (int i = 0; i < audioCurves.Length; i++)
            {
                AudioSourceInspector.AudioCurveWrapper audioCurveWrapper = audioCurves[i];
                if (audioCurveWrapper.curveProp != null)
                {
                    AnimationCurve animationCurve = audioCurveWrapper.curveProp.animationCurveValue;
                    bool           flag;
                    if (audioCurveWrapper.type == AudioSourceInspector.AudioCurveType.Volume)
                    {
                        AudioRolloffMode enumValueIndex = (AudioRolloffMode)this.m_RolloffMode.enumValueIndex;
                        if (this.m_RolloffMode.hasMultipleDifferentValues)
                        {
                            flag = false;
                        }
                        else if (enumValueIndex == AudioRolloffMode.Custom)
                        {
                            flag = !audioCurveWrapper.curveProp.hasMultipleDifferentValues;
                        }
                        else
                        {
                            flag = (!this.m_MinDistance.hasMultipleDifferentValues && !this.m_MaxDistance.hasMultipleDifferentValues);
                            if (enumValueIndex == AudioRolloffMode.Linear)
                            {
                                animationCurve = AnimationCurve.Linear(this.m_MinDistance.floatValue / this.m_MaxDistance.floatValue, 1f, 1f, 0f);
                            }
                            else if (enumValueIndex == AudioRolloffMode.Logarithmic)
                            {
                                animationCurve = AudioSourceInspector.Logarithmic(this.m_MinDistance.floatValue / this.m_MaxDistance.floatValue, 1f, 1f);
                            }
                        }
                    }
                    else
                    {
                        flag = !audioCurveWrapper.curveProp.hasMultipleDifferentValues;
                    }
                    if (flag)
                    {
                        if (animationCurve.length == 0)
                        {
                            Debug.LogError(audioCurveWrapper.legend.text + " curve has no keys!");
                        }
                        else
                        {
                            list.Add(this.GetCurveWrapper(animationCurve, audioCurveWrapper));
                        }
                    }
                }
            }
            return(list.ToArray());
        }
        private CurveWrapper[] GetCurveWrapperArray()
        {
            List <CurveWrapper> curveWrapperList = new List <CurveWrapper>();

            foreach (AudioSourceInspector.AudioCurveWrapper audioCurve in this.m_AudioCurves)
            {
                if (audioCurve.curveProp != null)
                {
                    AnimationCurve curve = audioCurve.curveProp.animationCurveValue;
                    bool           flag;
                    if (audioCurve.type == AudioSourceInspector.AudioCurveType.Volume)
                    {
                        AudioRolloffMode enumValueIndex = (AudioRolloffMode)this.m_RolloffMode.enumValueIndex;
                        if (this.m_RolloffMode.hasMultipleDifferentValues)
                        {
                            flag = false;
                        }
                        else if (enumValueIndex == AudioRolloffMode.Custom)
                        {
                            flag = !audioCurve.curveProp.hasMultipleDifferentValues;
                        }
                        else
                        {
                            flag = !this.m_MinDistance.hasMultipleDifferentValues && !this.m_MaxDistance.hasMultipleDifferentValues;
                            if (enumValueIndex == AudioRolloffMode.Linear)
                            {
                                curve = AnimationCurve.Linear(this.m_MinDistance.floatValue / this.m_MaxDistance.floatValue, 1f, 1f, 0.0f);
                            }
                            else if (enumValueIndex == AudioRolloffMode.Logarithmic)
                            {
                                curve = AudioSourceInspector.Logarithmic(this.m_MinDistance.floatValue / this.m_MaxDistance.floatValue, 1f, 1f);
                            }
                        }
                    }
                    else
                    {
                        flag = !audioCurve.curveProp.hasMultipleDifferentValues;
                    }
                    if (flag)
                    {
                        if (curve.length == 0)
                        {
                            Debug.LogError((object)(audioCurve.legend.text + " curve has no keys!"));
                        }
                        else
                        {
                            curveWrapperList.Add(this.GetCurveWrapper(curve, audioCurve));
                        }
                    }
                }
            }
            return(curveWrapperList.ToArray());
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            AudioSourceInspector.AnimProp(
                EditorGUIUtility.TrTextContent("Cutoff Frequency"),
                m_LowpassLevelCustomCurve,
                0.0f, AudioSourceInspector.kMaxCutoffFrequency, true);

            EditorGUILayout.PropertyField(m_LowpassResonanceQ);

            serializedObject.ApplyModifiedProperties();
        }
        public override void OnInspectorGUI()
        {
            serializedObject.Update();

            AudioSourceInspector.AnimProp(
                Styles.LowpassLevelCustomCurveTooltip,
                m_LowpassLevelCustomCurve,
                10.0f, AudioSourceInspector.kMaxCutoffFrequency, true);

            EditorGUILayout.PropertyField(m_LowpassResonanceQ, Styles.LowpassResonanceQTooltip);

            serializedObject.ApplyModifiedProperties();
        }
Exemple #7
0
 private void Audio3DGUI()
 {
     EditorGUILayout.Slider(this.m_DopplerLevel, 0f, 5f, AudioSourceInspector.ms_Styles.dopplerLevelLabel, new GUILayoutOption[0]);
     EditorGUI.BeginChangeCheck();
     AudioSourceInspector.AnimProp(AudioSourceInspector.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))
     {
         SerializedProperty arg_C5_0 = this.m_AudioCurves[0].curveProp;
         GUIContent         arg_C5_1 = AudioSourceInspector.ms_Styles.rolloffLabel;
         if (AudioSourceInspector.< > f__mg$cache0 == null)
         {
             AudioSourceInspector.< > f__mg$cache0 = new TargetChoiceHandler.TargetChoiceMenuFunction(AudioSourceInspector.SetRolloffToTarget);
         }
         EditorGUILayout.TargetChoiceField(arg_C5_0, arg_C5_1, AudioSourceInspector.< > f__mg$cache0, new GUILayoutOption[0]);
        internal static void AnimProp(GUIContent label, SerializedProperty prop, float min, float max, bool useNormalizedValue)
        {
            AudioSourceInspector.InitStyles();
            if (prop.hasMultipleDifferentValues)
            {
                EditorGUILayout.TargetChoiceField(prop, label, new GUILayoutOption[0]);
                return;
            }
            AnimationCurve animationCurveValue = prop.animationCurveValue;

            if (animationCurveValue == null)
            {
                Debug.LogError(label.text + " curve is null!");
                return;
            }
            if (animationCurveValue.length == 0)
            {
                Debug.LogError(label.text + " curve has no keys!");
                return;
            }
            if (animationCurveValue.length != 1)
            {
                using (new EditorGUI.DisabledScope(true))
                {
                    EditorGUILayout.LabelField(label.text, AudioSourceInspector.ms_Styles.controlledByCurveLabel, new GUILayoutOption[0]);
                }
            }
            else
            {
                float num = (!useNormalizedValue) ? animationCurveValue.keys[0].value : Mathf.Lerp(min, max, animationCurveValue.keys[0].value);
                num = MathUtils.DiscardLeastSignificantDecimal(num);
                EditorGUI.BeginChangeCheck();
                if (max > min)
                {
                    num = EditorGUILayout.Slider(label, num, min, max, new GUILayoutOption[0]);
                }
                else
                {
                    num = EditorGUILayout.Slider(label, num, max, min, new GUILayoutOption[0]);
                }
                if (EditorGUI.EndChangeCheck())
                {
                    Keyframe key = animationCurveValue.keys[0];
                    key.time  = 0f;
                    key.value = ((!useNormalizedValue) ? num : Mathf.InverseLerp(min, max, num));
                    animationCurveValue.MoveKey(0, key);
                }
            }
            prop.animationCurveValue = animationCurveValue;
        }
 internal static void AnimProp(GUIContent label, SerializedProperty prop, float min, float max, bool useNormalizedValue)
 {
     AudioSourceInspector.InitStyles();
     if (prop.hasMultipleDifferentValues)
     {
         EditorGUILayout.TargetChoiceField(prop, label);
     }
     else
     {
         AnimationCurve animationCurveValue = prop.animationCurveValue;
         if (animationCurveValue == null)
         {
             Debug.LogError((object)(label.text + " curve is null!"));
         }
         else if (animationCurveValue.length == 0)
         {
             Debug.LogError((object)(label.text + " curve has no keys!"));
         }
         else
         {
             if (animationCurveValue.length != 1)
             {
                 EditorGUI.BeginDisabledGroup(true);
                 EditorGUILayout.LabelField(label.text, AudioSourceInspector.ms_Styles.controlledByCurveLabel, new GUILayoutOption[0]);
                 EditorGUI.EndDisabledGroup();
             }
             else
             {
                 float num1 = MathUtils.DiscardLeastSignificantDecimal(!useNormalizedValue ? animationCurveValue.keys[0].value : Mathf.Lerp(min, max, animationCurveValue.keys[0].value));
                 EditorGUI.BeginChangeCheck();
                 float num2 = (double)max <= (double)min ? EditorGUILayout.Slider(label, num1, max, min, new GUILayoutOption[0]) : EditorGUILayout.Slider(label, num1, min, max, new GUILayoutOption[0]);
                 if (EditorGUI.EndChangeCheck())
                 {
                     Keyframe key = animationCurveValue.keys[0];
                     key.time  = 0.0f;
                     key.value = !useNormalizedValue ? num2 : Mathf.InverseLerp(min, max, num2);
                     animationCurveValue.MoveKey(0, key);
                 }
             }
             prop.animationCurveValue = animationCurveValue;
         }
     }
 }
        private static AnimationCurve Logarithmic(float timeStart, float timeEnd, float logBase)
        {
            List <Keyframe> keyframeList = new List <Keyframe>();
            float           num1         = 2f;

            timeStart = Mathf.Max(timeStart, 0.0001f);
            float num2 = timeStart;

            while ((double)num2 < (double)timeEnd)
            {
                float num3 = AudioSourceInspector.LogarithmicValue(num2, timeStart, logBase);
                float num4 = num2 / 50f;
                float num5 = (float)(((double)AudioSourceInspector.LogarithmicValue(num2 + num4, timeStart, logBase) - (double)AudioSourceInspector.LogarithmicValue(num2 - num4, timeStart, logBase)) / ((double)num4 * 2.0));
                keyframeList.Add(new Keyframe(num2, num3, num5, num5));
                num2 *= num1;
            }
            float num6 = AudioSourceInspector.LogarithmicValue(timeEnd, timeStart, logBase);
            float num7 = timeEnd / 50f;
            float num8 = (float)(((double)AudioSourceInspector.LogarithmicValue(timeEnd + num7, timeStart, logBase) - (double)AudioSourceInspector.LogarithmicValue(timeEnd - num7, timeStart, logBase)) / ((double)num7 * 2.0));

            keyframeList.Add(new Keyframe(timeEnd, num6, num8, num8));
            return(new AnimationCurve(keyframeList.ToArray()));
        }
Exemple #11
0
 public override void OnInspectorGUI()
 {
     if (!Application.HasAdvancedLicense())
     {
         GUILayout.BeginHorizontal(new GUILayoutOption[0]);
         GUIContent content = new GUIContent("This is only available in the Pro version of Unity.");
         GUILayout.Label(content, EditorStyles.helpBox, new GUILayoutOption[0]);
         GUILayout.EndHorizontal();
     }
     base.serializedObject.Update();
     EditorGUI.BeginChangeCheck();
     AudioSourceInspector.AnimProp(new GUIContent("Cutoff Frequency"), this.m_LowpassLevelCustomCurve, 22000f, 0f, true);
     if (EditorGUI.EndChangeCheck())
     {
         AnimationCurve animationCurveValue = this.m_LowpassLevelCustomCurve.animationCurveValue;
         if (animationCurveValue.length > 0)
         {
             this.m_CutoffFrequency.floatValue = Mathf.Lerp(22000f, 0f, animationCurveValue.keys[0].value);
         }
     }
     EditorGUILayout.PropertyField(this.m_LowpassResonanceQ, new GUILayoutOption[0]);
     base.serializedObject.ApplyModifiedProperties();
 }
Exemple #12
0
        private static AnimationCurve Logarithmic(float timeStart, float timeEnd, float logBase)
        {
            List <Keyframe> list = new List <Keyframe>();
            float           num  = 2f;

            timeStart = Mathf.Max(timeStart, 0.0001f);
            float value;
            float num3;
            float num4;

            for (float num2 = timeStart; num2 < timeEnd; num2 *= num)
            {
                value = AudioSourceInspector.LogarithmicValue(num2, timeStart, logBase);
                num3  = num2 / 50f;
                num4  = (AudioSourceInspector.LogarithmicValue(num2 + num3, timeStart, logBase) - AudioSourceInspector.LogarithmicValue(num2 - num3, timeStart, logBase)) / (num3 * 2f);
                list.Add(new Keyframe(num2, value, num4, num4));
            }
            value = AudioSourceInspector.LogarithmicValue(timeEnd, timeStart, logBase);
            num3  = timeEnd / 50f;
            num4  = (AudioSourceInspector.LogarithmicValue(timeEnd + num3, timeStart, logBase) - AudioSourceInspector.LogarithmicValue(timeEnd - num3, timeStart, logBase)) / (num3 * 2f);
            list.Add(new Keyframe(timeEnd, value, num4, num4));
            return(new AnimationCurve(list.ToArray()));
        }
		private CurveWrapper GetCurveWrapper(AnimationCurve curve, AudioSourceInspector.AudioCurveWrapper audioCurve)
		{
			float num = EditorGUIUtility.isProSkin ? 1f : 0.9f;
			Color b = new Color(num, num, num, 1f);
			CurveWrapper curveWrapper = new CurveWrapper();
			curveWrapper.id = audioCurve.id;
			curveWrapper.groupId = -1;
			curveWrapper.color = audioCurve.color * b;
			curveWrapper.hidden = false;
			curveWrapper.readOnly = false;
			curveWrapper.renderer = new NormalCurveRenderer(curve);
			curveWrapper.renderer.SetCustomRange(0f, 1f);
			curveWrapper.getAxisUiScalarsCallback = new CurveWrapper.GetAxisScalarsCallback(this.GetAxisScalars);
			return curveWrapper;
		}
        public override void OnInspectorGUI()
        {
            AudioSourceInspector.InitStyles();
            this.serializedObject.Update();
            if (this.m_LowpassObject != null)
            {
                this.m_LowpassObject.Update();
            }
            this.HandleLowPassFilter();
            foreach (AudioSourceInspector.AudioCurveWrapper audioCurve in this.m_AudioCurves)
            {
                CurveWrapper curveWrapperById = this.m_CurveEditor.getCurveWrapperById(audioCurve.id);
                if (audioCurve.curveProp != null)
                {
                    AnimationCurve animationCurveValue = audioCurve.curveProp.animationCurveValue;
                    if (curveWrapperById == null != audioCurve.curveProp.hasMultipleDifferentValues)
                    {
                        this.m_RefreshCurveEditor = true;
                    }
                    else if (curveWrapperById != null)
                    {
                        if (curveWrapperById.curve.length == 0)
                        {
                            this.m_RefreshCurveEditor = true;
                        }
                        else if (animationCurveValue.length >= 1 && (double)animationCurveValue.keys[0].value != (double)curveWrapperById.curve.keys[0].value)
                        {
                            this.m_RefreshCurveEditor = true;
                        }
                    }
                }
                else if (curveWrapperById != null)
                {
                    this.m_RefreshCurveEditor = true;
                }
            }
            this.UpdateWrappersAndLegend();
            EditorGUILayout.PropertyField(this.m_AudioClip, AudioSourceInspector.ms_Styles.audioClipLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUILayout.PropertyField(this.m_OutputAudioMixerGroup, AudioSourceInspector.ms_Styles.outputMixerGroupLabel, new GUILayoutOption[0]);
            EditorGUILayout.PropertyField(this.m_Mute);
            if (AudioUtil.canUseSpatializerEffect)
            {
                EditorGUILayout.PropertyField(this.m_Spatialize);
            }
            EditorGUILayout.PropertyField(this.m_BypassEffects);
            bool flag = ((IEnumerable <UnityEngine.Object>) this.targets).Any <UnityEngine.Object>((Func <UnityEngine.Object, bool>)(t => (UnityEngine.Object)(t as AudioSource).outputAudioMixerGroup != (UnityEngine.Object)null));

            if (flag)
            {
                EditorGUI.BeginDisabledGroup(true);
            }
            EditorGUILayout.PropertyField(this.m_BypassListenerEffects);
            if (flag)
            {
                EditorGUI.EndDisabledGroup();
            }
            EditorGUILayout.PropertyField(this.m_BypassReverbZones);
            EditorGUILayout.PropertyField(this.m_PlayOnAwake);
            EditorGUILayout.PropertyField(this.m_Loop);
            EditorGUILayout.Space();
            EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.priorityLeftLabel, AudioSourceInspector.ms_Styles.priorityRightLabel);
            EditorGUILayout.IntSlider(this.m_Priority, 0, 256, AudioSourceInspector.ms_Styles.priorityLabel, new GUILayoutOption[0]);
            EditorGUIUtility.sliderLabels.SetLabels((GUIContent)null, (GUIContent)null);
            EditorGUILayout.Space();
            EditorGUILayout.Slider(this.m_Volume, 0.0f, 1f, AudioSourceInspector.ms_Styles.volumeLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUILayout.Slider(this.m_Pitch, -3f, 3f, AudioSourceInspector.ms_Styles.pitchLabel, new GUILayoutOption[0]);
            EditorGUILayout.Space();
            EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.panLeftLabel, AudioSourceInspector.ms_Styles.panRightLabel);
            EditorGUILayout.Slider(this.m_Pan2D, -1f, 1f, AudioSourceInspector.ms_Styles.panStereoLabel, new GUILayoutOption[0]);
            EditorGUIUtility.sliderLabels.SetLabels((GUIContent)null, (GUIContent)null);
            EditorGUILayout.Space();
            EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.spatialLeftLabel, AudioSourceInspector.ms_Styles.spatialRightLabel);
            AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spatialBlendLabel, this.m_AudioCurves[1].curveProp, 0.0f, 1f, false);
            EditorGUIUtility.sliderLabels.SetLabels((GUIContent)null, (GUIContent)null);
            EditorGUILayout.Space();
            AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.reverbZoneMixLabel, this.m_AudioCurves[4].curveProp, 0.0f, 1.1f, false);
            EditorGUILayout.Space();
            this.m_Expanded3D = EditorGUILayout.Foldout(this.m_Expanded3D, "3D Sound Settings");
            if (this.m_Expanded3D)
            {
                ++EditorGUI.indentLevel;
                this.Audio3DGUI();
                --EditorGUI.indentLevel;
            }
            this.serializedObject.ApplyModifiedProperties();
            if (this.m_LowpassObject == null)
            {
                return;
            }
            this.m_LowpassObject.ApplyModifiedProperties();
        }
Exemple #15
0
 public override void OnInspectorGUI()
 {
     AudioSourceInspector.InitStyles();
     base.serializedObject.Update();
     if (this.m_LowpassObject != null)
     {
         this.m_LowpassObject.Update();
     }
     this.HandleLowPassFilter();
     AudioSourceInspector.AudioCurveWrapper[] audioCurves = this.m_AudioCurves;
     for (int i = 0; i < audioCurves.Length; i++)
     {
         AudioSourceInspector.AudioCurveWrapper audioCurveWrapper = audioCurves[i];
         CurveWrapper curveWrapperFromID = this.m_CurveEditor.GetCurveWrapperFromID(audioCurveWrapper.id);
         if (audioCurveWrapper.curveProp != null)
         {
             AnimationCurve animationCurveValue = audioCurveWrapper.curveProp.animationCurveValue;
             if (curveWrapperFromID == null != audioCurveWrapper.curveProp.hasMultipleDifferentValues)
             {
                 this.m_RefreshCurveEditor = true;
             }
             else if (curveWrapperFromID != null)
             {
                 if (curveWrapperFromID.curve.length == 0)
                 {
                     this.m_RefreshCurveEditor = true;
                 }
                 else if (animationCurveValue.length >= 1 && animationCurveValue.keys[0].value != curveWrapperFromID.curve.keys[0].value)
                 {
                     this.m_RefreshCurveEditor = true;
                 }
             }
         }
         else if (curveWrapperFromID != null)
         {
             this.m_RefreshCurveEditor = true;
         }
     }
     this.UpdateWrappersAndLegend();
     EditorGUILayout.PropertyField(this.m_AudioClip, AudioSourceInspector.ms_Styles.audioClipLabel, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUILayout.PropertyField(this.m_OutputAudioMixerGroup, AudioSourceInspector.ms_Styles.outputMixerGroupLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_Mute, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_BypassEffects, new GUILayoutOption[0]);
     if (base.targets.Any((UnityEngine.Object t) => (t as AudioSource).outputAudioMixerGroup != null))
     {
         using (new EditorGUI.DisabledScope(true))
         {
             EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]);
         }
     }
     else
     {
         EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]);
     }
     EditorGUILayout.PropertyField(this.m_BypassReverbZones, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_PlayOnAwake, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_Loop, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.priorityLeftLabel, AudioSourceInspector.ms_Styles.priorityRightLabel);
     EditorGUILayout.IntSlider(this.m_Priority, 0, 256, AudioSourceInspector.ms_Styles.priorityLabel, new GUILayoutOption[0]);
     EditorGUIUtility.sliderLabels.SetLabels(null, null);
     EditorGUILayout.Space();
     EditorGUILayout.Slider(this.m_Volume, 0f, 1f, AudioSourceInspector.ms_Styles.volumeLabel, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUILayout.Slider(this.m_Pitch, -3f, 3f, AudioSourceInspector.ms_Styles.pitchLabel, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.panLeftLabel, AudioSourceInspector.ms_Styles.panRightLabel);
     EditorGUILayout.Slider(this.m_Pan2D, -1f, 1f, AudioSourceInspector.ms_Styles.panStereoLabel, new GUILayoutOption[0]);
     EditorGUIUtility.sliderLabels.SetLabels(null, null);
     EditorGUILayout.Space();
     EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.spatialLeftLabel, AudioSourceInspector.ms_Styles.spatialRightLabel);
     AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spatialBlendLabel, this.m_AudioCurves[1].curveProp, 0f, 1f, false);
     EditorGUIUtility.sliderLabels.SetLabels(null, null);
     EditorGUILayout.Space();
     AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.reverbZoneMixLabel, this.m_AudioCurves[4].curveProp, 0f, 1.1f, false);
     EditorGUILayout.Space();
     this.m_Expanded3D = EditorGUILayout.Foldout(this.m_Expanded3D, "3D Sound Settings", true);
     if (this.m_Expanded3D)
     {
         EditorGUI.indentLevel++;
         this.Audio3DGUI();
         EditorGUI.indentLevel--;
     }
     if (AudioUtil.canUseSpatializerEffect)
     {
         EditorGUILayout.PropertyField(this.m_Spatialize, AudioSourceInspector.ms_Styles.spatializeLabel, new GUILayoutOption[0]);
         if (this.m_Spatialize.boolValue && !this.m_Spatialize.hasMultipleDifferentValues)
         {
             for (int j = 0; j < base.targets.Length; j++)
             {
                 AudioSource          audioSource          = base.targets[j] as AudioSource;
                 AudioSourceExtension audioSourceExtension = (!(audioSource != null)) ? null : AudioExtensionManager.GetSpatializerExtension(audioSource);
                 if (audioSource != null && audioSource.spatialize && audioSource.isPlaying)
                 {
                     if (audioSourceExtension == null)
                     {
                         audioSourceExtension = AudioExtensionManager.AddSpatializerExtension(audioSource);
                     }
                     AudioExtensionManager.GetReadyToPlay(audioSourceExtension);
                 }
             }
             EditorGUI.indentLevel++;
             EditorGUILayout.PropertyField(this.m_SpatializePostEffects, AudioSourceInspector.ms_Styles.spatializePostEffectsLabel, new GUILayoutOption[0]);
             bool flag = (this.m_AddSpatializerExtension && !this.m_AddSpatializerExtensionMixedValues) || !base.serializedObject.isEditingMultipleObjects;
             if (AudioExtensionManager.IsSourceSpatializerExtensionRegistered() && flag)
             {
                 EditorGUI.showMixedValue = this.m_AddSpatializerExtensionMixedValues;
                 bool flag2 = EditorGUILayout.Toggle(AudioSourceInspector.ms_Styles.addSpatializerExtensionLabel, this.m_AddSpatializerExtension, new GUILayoutOption[0]);
                 EditorGUI.showMixedValue = false;
                 bool flag3 = false;
                 if (this.m_AddSpatializerExtension != flag2)
                 {
                     this.m_AddSpatializerExtension = flag2;
                     if (this.m_AddSpatializerExtension)
                     {
                         this.CreateExtensionEditors();
                         if (this.m_SpatializerEditor != null)
                         {
                             flag3 = this.m_SpatializerEditor.FindAudioExtensionProperties(base.serializedObject);
                         }
                     }
                     else
                     {
                         this.ClearExtensionProperties();
                         this.DestroyExtensionEditors();
                         flag3 = false;
                     }
                 }
                 else if (this.m_SpatializerEditor != null)
                 {
                     flag3 = this.m_SpatializerEditor.FindAudioExtensionProperties(base.serializedObject);
                     if (!flag3)
                     {
                         this.m_AddSpatializerExtension = false;
                         this.ClearExtensionProperties();
                         this.DestroyExtensionEditors();
                     }
                 }
                 if (this.m_SpatializerEditor != null && flag3)
                 {
                     EditorGUI.indentLevel++;
                     this.m_SpatializerEditor.OnAudioSourceGUI();
                     EditorGUI.indentLevel--;
                     for (int k = 0; k < base.targets.Length; k++)
                     {
                         AudioSource          audioSource2          = base.targets[k] as AudioSource;
                         AudioSourceExtension audioSourceExtension2 = (!(audioSource2 != null)) ? null : AudioExtensionManager.GetSpatializerExtension(audioSource2);
                         if (audioSource2 != null && audioSourceExtension2 != null && audioSource2.isPlaying)
                         {
                             string name = AudioExtensionManager.GetSourceSpatializerExtensionType().Name;
                             for (int l = 0; l < this.m_SpatializerEditor.GetNumExtensionProperties(); l++)
                             {
                                 PropertyName extensionPropertyName = this.m_SpatializerEditor.GetExtensionPropertyName(l);
                                 float        propertyValue         = 0f;
                                 if (audioSource2.ReadExtensionProperty(name, extensionPropertyName, ref propertyValue))
                                 {
                                     audioSourceExtension2.WriteExtensionProperty(extensionPropertyName, propertyValue);
                                 }
                             }
                         }
                     }
                 }
             }
         }
     }
     base.serializedObject.ApplyModifiedProperties();
     if (this.m_LowpassObject != null)
     {
         this.m_LowpassObject.ApplyModifiedProperties();
     }
 }
Exemple #16
0
 public override void OnInspectorGUI()
 {
     AudioSourceInspector.InitStyles();
     base.serializedObject.Update();
     if (this.m_LowpassObject != null)
     {
         this.m_LowpassObject.Update();
     }
     this.HandleLowPassFilter();
     AudioSourceInspector.AudioCurveWrapper[] audioCurves = this.m_AudioCurves;
     for (int i = 0; i < audioCurves.Length; i++)
     {
         AudioSourceInspector.AudioCurveWrapper audioCurveWrapper = audioCurves[i];
         CurveWrapper curveWrapperFromID = this.m_CurveEditor.GetCurveWrapperFromID(audioCurveWrapper.id);
         if (audioCurveWrapper.curveProp != null)
         {
             AnimationCurve animationCurveValue = audioCurveWrapper.curveProp.animationCurveValue;
             if (curveWrapperFromID == null != audioCurveWrapper.curveProp.hasMultipleDifferentValues)
             {
                 this.m_RefreshCurveEditor = true;
             }
             else if (curveWrapperFromID != null)
             {
                 if (curveWrapperFromID.curve.length == 0)
                 {
                     this.m_RefreshCurveEditor = true;
                 }
                 else if (animationCurveValue.length >= 1 && animationCurveValue.keys[0].value != curveWrapperFromID.curve.keys[0].value)
                 {
                     this.m_RefreshCurveEditor = true;
                 }
             }
         }
         else if (curveWrapperFromID != null)
         {
             this.m_RefreshCurveEditor = true;
         }
     }
     this.UpdateWrappersAndLegend();
     EditorGUILayout.PropertyField(this.m_AudioClip, AudioSourceInspector.ms_Styles.audioClipLabel, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUILayout.PropertyField(this.m_OutputAudioMixerGroup, AudioSourceInspector.ms_Styles.outputMixerGroupLabel, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_Mute, new GUILayoutOption[0]);
     if (AudioUtil.canUseSpatializerEffect)
     {
         EditorGUILayout.PropertyField(this.m_Spatialize, AudioSourceInspector.ms_Styles.spatializeLabel, new GUILayoutOption[0]);
         using (new EditorGUI.DisabledScope(!this.m_Spatialize.boolValue))
         {
             EditorGUILayout.PropertyField(this.m_SpatializePostEffects, AudioSourceInspector.ms_Styles.spatializePostEffectsLabel, new GUILayoutOption[0]);
         }
     }
     EditorGUILayout.PropertyField(this.m_BypassEffects, new GUILayoutOption[0]);
     if (base.targets.Any((UnityEngine.Object t) => (t as AudioSource).outputAudioMixerGroup != null))
     {
         using (new EditorGUI.DisabledScope(true))
         {
             EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]);
         }
     }
     else
     {
         EditorGUILayout.PropertyField(this.m_BypassListenerEffects, new GUILayoutOption[0]);
     }
     EditorGUILayout.PropertyField(this.m_BypassReverbZones, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_PlayOnAwake, new GUILayoutOption[0]);
     EditorGUILayout.PropertyField(this.m_Loop, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.priorityLeftLabel, AudioSourceInspector.ms_Styles.priorityRightLabel);
     EditorGUILayout.IntSlider(this.m_Priority, 0, 256, AudioSourceInspector.ms_Styles.priorityLabel, new GUILayoutOption[0]);
     EditorGUIUtility.sliderLabels.SetLabels(null, null);
     EditorGUILayout.Space();
     EditorGUILayout.Slider(this.m_Volume, 0f, 1f, AudioSourceInspector.ms_Styles.volumeLabel, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUILayout.Slider(this.m_Pitch, -3f, 3f, AudioSourceInspector.ms_Styles.pitchLabel, new GUILayoutOption[0]);
     EditorGUILayout.Space();
     EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.panLeftLabel, AudioSourceInspector.ms_Styles.panRightLabel);
     EditorGUILayout.Slider(this.m_Pan2D, -1f, 1f, AudioSourceInspector.ms_Styles.panStereoLabel, new GUILayoutOption[0]);
     EditorGUIUtility.sliderLabels.SetLabels(null, null);
     EditorGUILayout.Space();
     EditorGUIUtility.sliderLabels.SetLabels(AudioSourceInspector.ms_Styles.spatialLeftLabel, AudioSourceInspector.ms_Styles.spatialRightLabel);
     AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.spatialBlendLabel, this.m_AudioCurves[1].curveProp, 0f, 1f, false);
     EditorGUIUtility.sliderLabels.SetLabels(null, null);
     EditorGUILayout.Space();
     AudioSourceInspector.AnimProp(AudioSourceInspector.ms_Styles.reverbZoneMixLabel, this.m_AudioCurves[4].curveProp, 0f, 1.1f, false);
     EditorGUILayout.Space();
     this.m_Expanded3D = EditorGUILayout.Foldout(this.m_Expanded3D, "3D Sound Settings", true);
     if (this.m_Expanded3D)
     {
         EditorGUI.indentLevel++;
         this.Audio3DGUI();
         EditorGUI.indentLevel--;
     }
     base.serializedObject.ApplyModifiedProperties();
     if (this.m_LowpassObject != null)
     {
         this.m_LowpassObject.ApplyModifiedProperties();
     }
 }
Exemple #17
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;
                        }
                    }
                }
            }
        }