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;
}