コード例 #1
0
        //Ani.SpeedUpOrStopThen(fun.smoothDeltaTime*3,() => {})
        public static IAnimation SpeedUpOrStopThen(this IAnimation ani, double seconds, Action then)
        {
            if (ani == null || ani.IsFinished)
            {
                then();
                return(ani);
            }

            var timeAni = ani as ITimeBased;

            if (timeAni != null)
            {
                var timePlusSeconds = Time.time + seconds;
                // if hasn't started yet
                if (timeAni.Range.From > Time.time)
                {
                    timeAni.Range.To = timeAni.Range.From + (float)seconds;
                }
                // if in the middle
                else if (timePlusSeconds >= timeAni.Range.From && timePlusSeconds <= timeAni.Range.To)
                {
                    timeAni.Range.ResizeRemainingTo(seconds);
                }
                ani.Then(then);
                return(ani);
            }
            ani.Finish();
            then();
            return(ani);
        }