| 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354 | using System;using UnityEngine;using UnityEngine.Assertions;namespace UnityUIPlayables{    [Serializable]    public class Curve    {        [SerializeField] private CurveType _curveType;        [SerializeField] [EnabledIf(nameof(_curveType), (int) CurveType.Easing)]        private EaseType _easeType;        [NormalizedAnimationCurve(false)]        [EnabledIf(nameof(_curveType), (int) CurveType.AnimationCurve)]        [SerializeField]        private AnimationCurve _animationCurve;        public float Evaluate(float progress)        {            Assert.IsTrue(progress >= 0.0f);            Assert.IsTrue(progress <= 1.0f);            switch (_curveType)            {                case CurveType.Easing:                    return Easings.Interpolate(progress, _easeType);                case CurveType.AnimationCurve:                    return _animationCurve.Evaluate(progress);                default:                    throw new ArgumentOutOfRangeException();            }        }                internal static Curve CreateFromEasing(EaseType easeType)        {            return new Curve            {                _curveType = CurveType.Easing,                _easeType = easeType            };        }                internal static Curve CreateFromAnimationCurve(AnimationCurve animationCurve)        {            return new Curve            {                _curveType = CurveType.AnimationCurve,                _animationCurve = animationCurve            };        }    }}
 |