InitStyles() private static method

private static InitStyles ( ) : void
return void
        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;
         }
     }
 }
Example #3
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();
     }
 }
        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();
        }
Example #5
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();
     }
 }