PowerSlider() static private method

static private PowerSlider ( GUIContent label, float value, float leftValue, float rightValue, float power ) : float
label UnityEngine.GUIContent
value float
leftValue float
rightValue float
power float
return float
Beispiel #1
0
        public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
        {
            EditorGUI.BeginChangeCheck();
            float  fieldWidth = EditorGUIUtility.fieldWidth;
            string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
            bool   flag = controller.ContainsExposedParameter(path.parameter);

            EditorGUIUtility.fieldWidth       = 70f;
            EditorGUI.kFloatFieldFormatString = "F2";
            EditorGUI.s_UnitString            = unit;
            GUIContent content = label;

            if (flag)
            {
                content = GUIContent.Temp(label.text + " ➔", label.tooltip);
            }
            float num2 = value * displayScale;

            num2 = EditorGUILayout.PowerSlider(content, num2, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
            EditorGUI.s_UnitString            = null;
            EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
            EditorGUIUtility.fieldWidth       = fieldWidth;
            if ((Event.current.type == EventType.ContextClick) && GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
            {
                ParameterTransitionType type;
                Event.current.Use();
                GenericMenu menu = new GenericMenu();
                if (!flag)
                {
                    if (< > f__mg$cache0 == null)
                    {
        public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
        {
            EditorGUI.BeginChangeCheck();
            float  fieldWidth        = EditorGUIUtility.fieldWidth;
            string fieldFormatString = EditorGUI.kFloatFieldFormatString;
            bool   flag = controller.ContainsExposedParameter(path.parameter);

            EditorGUIUtility.fieldWidth       = 70f;
            EditorGUI.kFloatFieldFormatString = "F2";
            EditorGUI.s_UnitString            = unit;
            GUIContent label1 = label;

            if (flag)
            {
                label1 = GUIContent.Temp(label.text + " ➔", label.tooltip);
            }
            float num1 = value * displayScale;
            float num2 = EditorGUILayout.PowerSlider(label1, num1, leftValue * displayScale, rightValue * displayScale, displayExponent, options);

            EditorGUI.s_UnitString            = (string)null;
            EditorGUI.kFloatFieldFormatString = fieldFormatString;
            EditorGUIUtility.fieldWidth       = fieldWidth;
            if (Event.current.type == EventType.ContextClick && GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
            {
                Event.current.Use();
                GenericMenu genericMenu = new GenericMenu();
                if (!flag)
                {
                    genericMenu.AddItem(new GUIContent("Expose '" + path.ResolveStringPath(false) + "' to script"), false, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ExposePopupCallback), (object)new AudioMixerEffectGUI.ExposedParamContext(controller, path));
                }
                else
                {
                    genericMenu.AddItem(new GUIContent("Unexpose"), false, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.UnexposePopupCallback), (object)new AudioMixerEffectGUI.ExposedParamContext(controller, path));
                }
                ParameterTransitionType type;
                controller.TargetSnapshot.GetTransitionTypeOverride(path.parameter, out type);
                genericMenu.AddSeparator(string.Empty);
                genericMenu.AddItem(new GUIContent("Linear Snapshot Transition"), type == ParameterTransitionType.Lerp, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object)new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Lerp));
                genericMenu.AddItem(new GUIContent("Smoothstep Snapshot Transition"), type == ParameterTransitionType.Smoothstep, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object)new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Smoothstep));
                genericMenu.AddItem(new GUIContent("Squared Snapshot Transition"), type == ParameterTransitionType.Squared, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object)new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Squared));
                genericMenu.AddItem(new GUIContent("SquareRoot Snapshot Transition"), type == ParameterTransitionType.SquareRoot, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object)new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.SquareRoot));
                genericMenu.AddItem(new GUIContent("BrickwallStart Snapshot Transition"), type == ParameterTransitionType.BrickwallStart, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object)new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallStart));
                genericMenu.AddItem(new GUIContent("BrickwallEnd Snapshot Transition"), type == ParameterTransitionType.BrickwallEnd, new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback), (object)new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallEnd));
                genericMenu.AddSeparator(string.Empty);
                genericMenu.ShowAsContext();
            }
            if (!EditorGUI.EndChangeCheck())
            {
                return(false);
            }
            value = num2 / displayScale;
            return(true);
        }
Beispiel #3
0
        public override void OnInspectorGUI()
        {
            base.serializedObject.Update();
            EditorGUILayout.PropertyField(this.m_EnableSuspend, Texts.m_EnableSuspendLabel, new GUILayoutOption[0]);
            EditorGUI.BeginDisabledGroup(!this.m_EnableSuspend.boolValue || this.m_EnableSuspend.hasMultipleDifferentValues);
            EditorGUI.BeginChangeCheck();
            EditorGUI.s_UnitString = Texts.dB;
            float floatValue = this.m_SuspendThreshold.floatValue;

            floatValue             = EditorGUILayout.PowerSlider(Texts.m_SuspendThresholdLabel, floatValue, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), 1f, new GUILayoutOption[0]);
            EditorGUI.s_UnitString = null;
            if (EditorGUI.EndChangeCheck())
            {
                this.m_SuspendThreshold.floatValue = floatValue;
            }
            EditorGUI.EndDisabledGroup();
            base.serializedObject.ApplyModifiedProperties();
        }
 public override void OnInspectorGUI()
 {
     serializedObject.Update();
     EditorGUILayout.PropertyField(m_EnableSuspend, Texts.m_EnableSuspendLabel);
     using (new EditorGUI.DisabledScope(!m_EnableSuspend.boolValue || m_EnableSuspend.hasMultipleDifferentValues))
     {
         EditorGUI.BeginChangeCheck();
         EditorGUI.s_UnitString = Texts.dB;
         float displayValue = m_SuspendThreshold.floatValue;
         displayValue           = EditorGUILayout.PowerSlider(Texts.m_SuspendThresholdLabel, displayValue, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), 1.0f);
         EditorGUI.s_UnitString = null;
         if (EditorGUI.EndChangeCheck())
         {
             m_SuspendThreshold.floatValue = displayValue;
         }
     }
     EditorGUILayout.PropertyField(m_UpdateMode, Texts.m_UpdateModeLabel);
     serializedObject.ApplyModifiedProperties();
 }
Beispiel #5
0
 public override void OnInspectorGUI()
 {
     base.serializedObject.Update();
     EditorGUILayout.PropertyField(this.m_EnableSuspend, AudioMixerControllerInspector.Texts.m_EnableSuspendLabel, new GUILayoutOption[0]);
     using (new EditorGUI.DisabledScope(!this.m_EnableSuspend.boolValue || this.m_EnableSuspend.hasMultipleDifferentValues))
     {
         EditorGUI.BeginChangeCheck();
         EditorGUI.s_UnitString = AudioMixerControllerInspector.Texts.dB;
         float num = this.m_SuspendThreshold.floatValue;
         num = EditorGUILayout.PowerSlider(AudioMixerControllerInspector.Texts.m_SuspendThresholdLabel, num, AudioMixerController.kMinVolume, AudioMixerController.GetMaxVolume(), 1f, new GUILayoutOption[0]);
         EditorGUI.s_UnitString = null;
         if (EditorGUI.EndChangeCheck())
         {
             this.m_SuspendThreshold.floatValue = num;
         }
     }
     EditorGUILayout.PropertyField(this.m_UpdateMode, AudioMixerControllerInspector.Texts.m_UpdateModeLabel, new GUILayoutOption[0]);
     base.serializedObject.ApplyModifiedProperties();
 }
Beispiel #6
0
        public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
        {
            EditorGUI.BeginChangeCheck();

            float  oldNumberWidth = EditorGUIUtility.fieldWidth;
            string origFormat     = EditorGUI.kFloatFieldFormatString;

            bool  exposed      = controller.ContainsExposedParameter(path.parameter);
            float displayValue = value * displayScale;

            EditorGUIUtility.fieldWidth       = 70f; // do not go over 70 because then sliders will not be shown when inspector has minimal width
            EditorGUI.kFloatFieldFormatString = kAudioSliderFloatFormat;
            EditorGUI.s_UnitString            = unit;

            try
            {
                GUIContent content = label;
                if (exposed)
                {
                    content = GUIContent.Temp(label.text + kExposedParameterUnicodeChar, label.tooltip);
                }

                displayValue = EditorGUILayout.PowerSlider(content, displayValue, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
            }
            finally
            {
                EditorGUI.s_UnitString            = null;
                EditorGUI.kFloatFieldFormatString = origFormat;
                EditorGUIUtility.fieldWidth       = oldNumberWidth;
            }

            if (Event.current.type == EventType.ContextClick)
            {
                Rect wholeSlider = GUILayoutUtility.topLevel.GetLast();
                if (wholeSlider.Contains(Event.current.mousePosition))
                {
                    Event.current.Use();

                    GenericMenu pm = new GenericMenu();
                    if (!exposed)
                    {
                        pm.AddItem(EditorGUIUtility.TrTextContent("Expose '" + path.ResolveStringPath(false) + "' to script"), false, ExposePopupCallback, new ExposedParamContext(controller, path));
                    }
                    else
                    {
                        pm.AddItem(EditorGUIUtility.TrTextContent("Unexpose"), false, UnexposePopupCallback, new ExposedParamContext(controller, path));
                    }

                    ParameterTransitionType existingType;
                    bool overrideExists = controller.TargetSnapshot.GetTransitionTypeOverride(path.parameter, out existingType);
                    System.Diagnostics.Debug.Assert(!overrideExists || existingType == ParameterTransitionType.Lerp);

                    pm.AddSeparator(string.Empty);
                    pm.AddItem(EditorGUIUtility.TrTextContent("Linear Snapshot Transition"), existingType == ParameterTransitionType.Lerp, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Lerp));
                    pm.AddItem(EditorGUIUtility.TrTextContent("Smoothstep Snapshot Transition"), existingType == ParameterTransitionType.Smoothstep, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Smoothstep));
                    pm.AddItem(EditorGUIUtility.TrTextContent("Squared Snapshot Transition"), existingType == ParameterTransitionType.Squared, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Squared));
                    pm.AddItem(EditorGUIUtility.TrTextContent("SquareRoot Snapshot Transition"), existingType == ParameterTransitionType.SquareRoot, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.SquareRoot));
                    pm.AddItem(EditorGUIUtility.TrTextContent("BrickwallStart Snapshot Transition"), existingType == ParameterTransitionType.BrickwallStart, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallStart));
                    pm.AddItem(EditorGUIUtility.TrTextContent("BrickwallEnd Snapshot Transition"), existingType == ParameterTransitionType.BrickwallEnd, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallEnd));
                    pm.AddItem(EditorGUIUtility.TrTextContent("Attenuation Snapshot Transition"), existingType == ParameterTransitionType.Attenuation, ParameterTransitionOverrideCallback, new ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Attenuation));
                    pm.AddSeparator(string.Empty);

                    pm.ShowAsContext();
                }
            }

            if (EditorGUI.EndChangeCheck())
            {
                value = displayValue / displayScale;
                return(true);
            }
            return(false);
        }
        public static bool Slider(GUIContent label, ref float value, float displayScale, float displayExponent, string unit, float leftValue, float rightValue, AudioMixerController controller, AudioParameterPath path, params GUILayoutOption[] options)
        {
            EditorGUI.BeginChangeCheck();
            float  fieldWidth = EditorGUIUtility.fieldWidth;
            string kFloatFieldFormatString = EditorGUI.kFloatFieldFormatString;
            bool   flag = controller.ContainsExposedParameter(path.parameter);

            EditorGUIUtility.fieldWidth       = 70f;
            EditorGUI.kFloatFieldFormatString = "F2";
            EditorGUI.s_UnitString            = unit;
            GUIContent label2 = label;

            if (flag)
            {
                label2 = GUIContent.Temp(label.text + " ➔", label.tooltip);
            }
            float num = value * displayScale;

            num = EditorGUILayout.PowerSlider(label2, num, leftValue * displayScale, rightValue * displayScale, displayExponent, options);
            EditorGUI.s_UnitString            = null;
            EditorGUI.kFloatFieldFormatString = kFloatFieldFormatString;
            EditorGUIUtility.fieldWidth       = fieldWidth;
            if (Event.current.type == EventType.ContextClick)
            {
                if (GUILayoutUtility.topLevel.GetLast().Contains(Event.current.mousePosition))
                {
                    Event.current.Use();
                    GenericMenu genericMenu = new GenericMenu();
                    if (!flag)
                    {
                        GenericMenu arg_120_0 = genericMenu;
                        GUIContent  arg_120_1 = EditorGUIUtility.TrTextContent("Expose '" + path.ResolveStringPath(false) + "' to script", null, null);
                        bool        arg_120_2 = false;
                        if (AudioMixerEffectGUI.< > f__mg$cache0 == null)
                        {
                            AudioMixerEffectGUI.< > f__mg$cache0 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ExposePopupCallback);
                        }
                        arg_120_0.AddItem(arg_120_1, arg_120_2, AudioMixerEffectGUI.< > f__mg$cache0, new AudioMixerEffectGUI.ExposedParamContext(controller, path));
                    }
                    else
                    {
                        GenericMenu arg_15F_0 = genericMenu;
                        GUIContent  arg_15F_1 = EditorGUIUtility.TrTextContent("Unexpose", null, null);
                        bool        arg_15F_2 = false;
                        if (AudioMixerEffectGUI.< > f__mg$cache1 == null)
                        {
                            AudioMixerEffectGUI.< > f__mg$cache1 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.UnexposePopupCallback);
                        }
                        arg_15F_0.AddItem(arg_15F_1, arg_15F_2, AudioMixerEffectGUI.< > f__mg$cache1, new AudioMixerEffectGUI.ExposedParamContext(controller, path));
                    }
                    ParameterTransitionType parameterTransitionType;
                    bool transitionTypeOverride = controller.TargetSnapshot.GetTransitionTypeOverride(path.parameter, out parameterTransitionType);
                    genericMenu.AddSeparator(string.Empty);
                    GenericMenu arg_1C6_0 = genericMenu;
                    GUIContent  arg_1C6_1 = EditorGUIUtility.TrTextContent("Linear Snapshot Transition", null, null);
                    bool        arg_1C6_2 = parameterTransitionType == ParameterTransitionType.Lerp;
                    if (AudioMixerEffectGUI.< > f__mg$cache2 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache2 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_1C6_0.AddItem(arg_1C6_1, arg_1C6_2, AudioMixerEffectGUI.< > f__mg$cache2, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Lerp));
                    GenericMenu arg_20A_0 = genericMenu;
                    GUIContent  arg_20A_1 = EditorGUIUtility.TrTextContent("Smoothstep Snapshot Transition", null, null);
                    bool        arg_20A_2 = parameterTransitionType == ParameterTransitionType.Smoothstep;
                    if (AudioMixerEffectGUI.< > f__mg$cache3 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache3 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_20A_0.AddItem(arg_20A_1, arg_20A_2, AudioMixerEffectGUI.< > f__mg$cache3, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Smoothstep));
                    GenericMenu arg_24E_0 = genericMenu;
                    GUIContent  arg_24E_1 = EditorGUIUtility.TrTextContent("Squared Snapshot Transition", null, null);
                    bool        arg_24E_2 = parameterTransitionType == ParameterTransitionType.Squared;
                    if (AudioMixerEffectGUI.< > f__mg$cache4 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache4 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_24E_0.AddItem(arg_24E_1, arg_24E_2, AudioMixerEffectGUI.< > f__mg$cache4, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.Squared));
                    GenericMenu arg_292_0 = genericMenu;
                    GUIContent  arg_292_1 = EditorGUIUtility.TrTextContent("SquareRoot Snapshot Transition", null, null);
                    bool        arg_292_2 = parameterTransitionType == ParameterTransitionType.SquareRoot;
                    if (AudioMixerEffectGUI.< > f__mg$cache5 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache5 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_292_0.AddItem(arg_292_1, arg_292_2, AudioMixerEffectGUI.< > f__mg$cache5, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.SquareRoot));
                    GenericMenu arg_2D6_0 = genericMenu;
                    GUIContent  arg_2D6_1 = EditorGUIUtility.TrTextContent("BrickwallStart Snapshot Transition", null, null);
                    bool        arg_2D6_2 = parameterTransitionType == ParameterTransitionType.BrickwallStart;
                    if (AudioMixerEffectGUI.< > f__mg$cache6 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache6 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_2D6_0.AddItem(arg_2D6_1, arg_2D6_2, AudioMixerEffectGUI.< > f__mg$cache6, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallStart));
                    GenericMenu arg_31A_0 = genericMenu;
                    GUIContent  arg_31A_1 = EditorGUIUtility.TrTextContent("BrickwallEnd Snapshot Transition", null, null);
                    bool        arg_31A_2 = parameterTransitionType == ParameterTransitionType.BrickwallEnd;
                    if (AudioMixerEffectGUI.< > f__mg$cache7 == null)
                    {
                        AudioMixerEffectGUI.< > f__mg$cache7 = new GenericMenu.MenuFunction2(AudioMixerEffectGUI.ParameterTransitionOverrideCallback);
                    }
                    arg_31A_0.AddItem(arg_31A_1, arg_31A_2, AudioMixerEffectGUI.< > f__mg$cache7, new AudioMixerEffectGUI.ParameterTransitionOverrideContext(controller, path.parameter, ParameterTransitionType.BrickwallEnd));
                    genericMenu.AddSeparator(string.Empty);
                    genericMenu.ShowAsContext();
                }
            }
            bool result;

            if (EditorGUI.EndChangeCheck())
            {
                value  = num / displayScale;
                result = true;
            }
            else
            {
                result = false;
            }
            return(result);
        }