UnityEditor.AudioSourceInspector.AnimProp C# (CSharp) Method

AnimProp() static private method

static private AnimProp ( GUIContent label, UnityEditor.SerializedProperty prop, float min, float max, bool useNormalizedValue ) : void
label UnityEngine.GUIContent
prop UnityEditor.SerializedProperty
min float
max float
useNormalizedValue bool
return void
        internal static void AnimProp(GUIContent label, SerializedProperty prop, float min, float max, bool useNormalizedValue)
        {
            InitStyles();
            if (prop.hasMultipleDifferentValues)
            {
                EditorGUILayout.TargetChoiceField(prop, label, new GUILayoutOption[0]);
            }
            else
            {
                AnimationCurve animationCurveValue = prop.animationCurveValue;
                if (animationCurveValue == null)
                {
                    Debug.LogError(label.text + " curve is null!");
                }
                else if (animationCurveValue.length == 0)
                {
                    Debug.LogError(label.text + " curve has no keys!");
                }
                else
                {
                    if (animationCurveValue.length != 1)
                    {
                        EditorGUI.BeginDisabledGroup(true);
                        EditorGUILayout.LabelField(label.text, ms_Styles.controlledByCurveLabel, new GUILayoutOption[0]);
                        EditorGUI.EndDisabledGroup();
                    }
                    else
                    {
                        float v = !useNormalizedValue ? animationCurveValue.keys[0].value : Mathf.Lerp(min, max, animationCurveValue.keys[0].value);
                        v = MathUtils.DiscardLeastSignificantDecimal(v);
                        EditorGUI.BeginChangeCheck();
                        if (max > min)
                        {
                            v = EditorGUILayout.Slider(label, v, min, max, new GUILayoutOption[0]);
                        }
                        else
                        {
                            v = EditorGUILayout.Slider(label, v, max, min, new GUILayoutOption[0]);
                        }
                        if (EditorGUI.EndChangeCheck())
                        {
                            Keyframe key = animationCurveValue.keys[0];
                            key.time = 0f;
                            key.value = !useNormalizedValue ? v : Mathf.InverseLerp(min, max, v);
                            animationCurveValue.MoveKey(0, key);
                        }
                    }
                    prop.animationCurveValue = animationCurveValue;
                }
            }
        }

Usage Example

示例#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();
 }
All Usage Examples Of UnityEditor.AudioSourceInspector::AnimProp