public static void UpdateReleaseCurve(SerializedProperty envProp, AnimationCurve curve) { var relaseCurveProp = envProp.FindPropertyRelative(nameof(Envelope.releaseCurve)); relaseCurveProp.animationCurveValue = curve; var releaseStartValue = AnimationCurveHelpers.GetFirstKeyValue(relaseCurveProp); var sustainValueProp = envProp.FindPropertyRelative(nameof(Envelope.sustainValue)); sustainValueProp.floatValue = releaseStartValue; var decayCurveProp = envProp.FindPropertyRelative(nameof(Envelope.decayCurve)); AnimationCurveHelpers.SetCurveEnd(decayCurveProp, releaseStartValue); var decayTimeProp = envProp.FindPropertyRelative(nameof(Envelope.decayTime)); if (decayTimeProp.floatValue == 0) { AnimationCurveHelpers.SetCurveStart(decayCurveProp, releaseStartValue); var attackCurveProp = envProp.FindPropertyRelative(nameof(Envelope.attackCurve)); AnimationCurveHelpers.SetCurveEnd(attackCurveProp, releaseStartValue); } }
public static void UpdateSustainValue(SerializedProperty envProp, float sustainValue) { SerializedProperty sustainValueProp = envProp.FindPropertyRelative(nameof(Envelope.sustainValue)); sustainValueProp.floatValue = sustainValue; var relaseCurveProp = envProp.FindPropertyRelative(nameof(Envelope.releaseCurve)); AnimationCurveHelpers.SetCurveStart(relaseCurveProp, sustainValue); var decayCurveProp = envProp.FindPropertyRelative(nameof(Envelope.decayCurve)); AnimationCurveHelpers.SetCurveEnd(decayCurveProp, sustainValue); var decayTimeProp = envProp.FindPropertyRelative(nameof(Envelope.decayTime)); if (decayTimeProp.floatValue == 0) { AnimationCurveHelpers.SetCurveStart(decayCurveProp, sustainValue); var attackCurveProp = envProp.FindPropertyRelative(nameof(Envelope.attackCurve)); AnimationCurveHelpers.SetCurveEnd(attackCurveProp, sustainValue); } }