/// <summary>Punches a RectTransform's anchoredPosition towards the given direction and then back to the starting one
 /// as if it was connected to the starting position via an elastic.
 /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary>
 /// <param name="punch">The direction and strength of the punch (added to the RectTransform's current position)</param>
 /// <param name="duration">The duration of the tween</param>
 /// <param name="vibrato">Indicates how much will the punch vibrate</param>
 /// <param name="elasticity">Represents how much (0 to 1) the vector will go beyond the starting position when bouncing backwards.
 /// 1 creates a full oscillation between the punch direction and the opposite direction,
 /// while 0 oscillates only between the punch and the start position</param>
 /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param>
 public static Tweener DOPunchAnchorPos(this RectTransform target, Vector2 punch, float duration, int vibrato = 10,
                                        float elasticity = 1, bool snapping = false)
 {
     return(DOTween.Punch(() => target.anchoredPosition, x => target.anchoredPosition = x, punch, duration, vibrato,
                          elasticity)
            .SetTarget(target).SetOptions(snapping));
 }
Example #2
0
 public static Tweener DOPunchRotation(this Transform target, Vector3 punch, float duration, int vibrato = 10, float elasticity = 1f)
 {
     return(DOTween.Punch(() => target.localEulerAngles, delegate(Vector3 x)
     {
         target.localRotation = Quaternion.Euler(x);
     }, punch, duration, vibrato, elasticity).SetTarget(target));
 }
Example #3
0
 public static Tweener DOPunchPosition(this Transform target, Vector3 punch, float duration, int vibrato = 10, float elasticity = 1f, bool snapping = false)
 {
     return(DOTween.Punch(() => target.localPosition, delegate(Vector3 x)
     {
         target.localPosition = x;
     }, punch, duration, vibrato, elasticity).SetTarget(target).SetOptions(snapping));
 }
Example #4
0
 public static Tweener DOPunchScale(this Transform target, Vector3 punch, float duration, int vibrato = 10, float elasticity = 1f)
 {
     return(DOTween.Punch(() => target.localScale, delegate(Vector3 x)
     {
         target.localScale = x;
     }, punch, duration, vibrato, elasticity).SetTarget(target));
 }
Example #5
0
 public static Tweener DOPunchAnchorPos(this RectTransform target, Vector2 punch, float duration, int vibrato = 10, float elasticity = 1f, bool snapping = false)
 {
     return(DOTween.Punch(() => (Vector3)target.anchoredPosition, delegate(Vector3 x) {
         target.anchoredPosition = x;
     }, (Vector3)punch, duration, vibrato, elasticity).SetTarget <TweenerCore <Vector3, Vector3[], Vector3ArrayOptions> >(target).SetOptions(snapping));
 }