Example #1
0
        /// <summary>
        /// 在指定的过渡时间内移动一个游戏对象到指定的Vector3位置
        /// </summary>
        /// <param name="target">目标游戏对象</param>
        /// <param name="start">开始位置</param>
        /// <param name="end">结束位置</param>
        /// <param name="duration">过渡时间</param>
        private static AiukVector3Tween DoMove(this GameObject target, Vector3 start, Vector3 end, float duration)
        {
            target.transform.position = start;
            var tween = AiukTweenManager.Tween(null, start, end, duration, t3 =>
            {
                target.transform.position = t3.CurrentValue;
            });

            return(tween);
        }
Example #2
0
        private static AiukVector3Tween DoLocalScale(GameObject target,
                                                     Vector3 start,
                                                     Vector3 end,
                                                     float duration,
                                                     Action <IAiukTween <Vector3> > completion = null)
        {
            var tween = AiukTweenManager.Tween(null, start, end, duration, t3 =>
            {
                target.transform.localScale = t3.CurrentValue;
            }, completion);

            return(tween);
        }
Example #3
0
        ///// <summary>
        ///// 在指定的过渡时间内移动一个游戏对象到指定的Vector3位置
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="start">开始位置</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //private static ColorTween DoColor(this IImage target, Color start, Color end, float duration)
        //{
        //    target.Color = start;
        //    var tween = TweenManager.Tween(null, start, end, duration, t3 =>
        //    {
        //        target.Color = t3.CurrentValue;
        //    }, null);
        //    return tween;
        //}

        ///// <summary>
        ///// 在指定的过渡时间内移动一个文字游戏对象到指定的Vector3位置
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="start">开始位置</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //public static ColorTween DoColorText(this IText target, Color start, Color end, float duration)
        //{
        //    target.Color = start;
        //    var tween = TweenManager.Tween(null, start, end, duration, t3 =>
        //    {
        //        target.Color = t3.CurrentValue;
        //    }, null);
        //    return tween;
        //}

        ///// <summary>
        ///// 在指定的过渡时间内改变一个图片游戏对象的颜色透明只
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //public static ColorTween DoColorA(this IImage target, float end, float duration)
        //{
        //    var startV3 = target.Color;
        //    var endV3 = new Color(target.Color.r, target.Color.b, target.Color.g, end);
        //    return DoColor(target, startV3, endV3, duration);
        //}

        ///// <summary>
        ///// 在指定的过渡时间内改变一个文字游戏对象的颜色透明只
        ///// </summary>
        ///// <param name="target">目标游戏对象</param>
        ///// <param name="end">结束位置</param>
        ///// <param name="duration">过渡时间</param>
        //public static ColorTween DoColorAText(this IText target, float end, float duration)
        //{
        //    var startV3 = target.Color;
        //    var endV3 = new Color(target.Color.r, target.Color.b, target.Color.g, end);
        //    return DoColorText(target, startV3, endV3, duration);
        //}

        #region 位置动画

        /// <summary>
        /// 在指定的过渡时间内移动一个游戏对象到指定的Vector3位置(本地坐标 )
        /// </summary>
        /// <param name="target">目标游戏对象</param>
        /// <param name="start">开始位置</param>
        /// <param name="end">结束位置</param>
        /// <param name="duration">过渡时间</param>
        /// <param name="friendName">对人友好的动画名</param>
        /// <param name="easeType">动画曲线类型。</param>
        public static AiukVector3Tween DoLocalMove(this GameObject target,
                                                   Vector3 start,
                                                   Vector3 end,
                                                   float duration,
                                                   string friendName     = null,
                                                   AiukEaseType easeType = AiukEaseType.Linear)
        {
            target.transform.localPosition = start;
            var tween = AiukTweenManager.Tween(null, start, end, duration, t3 =>
            {
                target.transform.localPosition = t3.CurrentValue;
            }, null, easeType, friendName);

            return(tween);
        }
Example #4
0
        /// <summary>
        /// 旋转物体的Z轴(左右)。
        /// </summary>
        /// <param name="target"></param>
        /// <param name="offset">旋转偏移值,如果为正则向左旋转,为负则向右旋转。</param>
        /// <param name="duration"></param>
        /// <param name="easeType"></param>
        /// <param name="friendName"></param>
        /// <returns></returns>
        public static AiukFloatTween DoRotateZ(this GameObject target,
                                               float offset,
                                               float duration,
                                               AiukEaseType easeType = AiukEaseType.Linear,
                                               string friendName     = null)
        {
            var startAngle = target.transform.rotation.eulerAngles.z;
            var endAngle   = startAngle + offset;
            var tween      = AiukTweenManager.Tween(null, startAngle, endAngle, duration, t =>
            {
                target.transform.rotation = Quaternion.identity;
                target.transform.Rotate(Camera.main.transform.forward, t.CurrentValue);
            }, null, easeType, friendName);

            return(tween);
        }