/// <summary> /// 缩放 /// </summary> /// <param name="obj">Transform</param> /// <param name="duration">时间</param> /// <param name="to">目标值</param> /// <returns></returns> public static ActionInterval CCScaleTo(this Transform obj, float duration, Vector3 to) { var action = CCActionVector3.Create(duration, obj.localScale, to); action.SetInitFunc(() => { return(obj.localScale); }); action.SetUpdate((t, result) => { obj.localScale = result; }); return(action); }
/// <summary> /// AnchoredPosition移动 /// </summary> /// <param name="obj">RectTransform</param> /// <param name="duration">时间</param> /// <param name="to">目标值</param> /// <returns></returns> public static ActionInterval CCAnchoredPositionTo(this RectTransform obj, float duration, Vector3 to) { var action = CCActionVector3.Create(duration, obj.anchoredPosition, to); action.SetInitFunc(() => { return(obj.anchoredPosition); }); action.SetUpdate((t, result) => { obj.anchoredPosition = result; }); return(action); }
/// <summary> /// 旋转 /// </summary> /// <param name="obj">Transform</param> /// <param name="duration">时间</param> /// <param name="to">目标值</param> /// <returns></returns> public static ActionInterval CCAnglesTo(this Transform obj, float duration, Vector3 to, bool relativeWorld = false) { var action = CCActionVector3.Create(duration, relativeWorld ? obj.eulerAngles : obj.localEulerAngles, to); action.SetInitFunc(() => { return(relativeWorld ? obj.eulerAngles : obj.localEulerAngles); }); action.SetUpdate((t, result) => { if (relativeWorld) { obj.eulerAngles = result; } else { obj.localEulerAngles = result; } }); return(action); }