示例#1
0
        /// <summary>
        /// This method will draw Logarithmic Slider with scale of -100.0 - 12.0 [dBFs]
        /// -100 [dBFs] value will be converted to NagativeInfinity which will be 0 in linear scale
        /// </summary>
        /// <param name="serializedProperty"></param>
        public static void DrawLogarithmicSlider(SerializedProperty serializedProperty)
        {
            var decibels = LogarithmicConverter.ConvertToDecibels(serializedProperty.floatValue);

            // Convert to decibels for display purpose.
            // Note: This won't be updated until serializedObject.ApplyModifiedProperties() is called
            serializedProperty.floatValue = decibels <= MIN_DECIBEL_VALUE ? float.NegativeInfinity : decibels;
            EditorGUILayout.Slider(serializedProperty, MIN_DECIBEL_VALUE, MAX_DECIBEL_VALUE);

            // Convert to linear value
            serializedProperty.floatValue = LogarithmicConverter.ConvertToLinear(serializedProperty.floatValue);
        }
示例#2
0
 static CustomSliderDrawer()
 {
     MAX_LINEAR_VALUE = LogarithmicConverter.ConvertToLinear(MAX_DECIBEL_VALUE);
 }