/// <summary>Tweens a RectTransform's anchorMin to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOAnchorMin(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { TweenerCore <Vector2, Vector2, VectorOptions> t = DG.Tweening.DOTween.To(() => target.anchorMin, x => target.anchorMin = x, endValue, duration); t.SetOptions(snapping).SetTarget(target); return(t); }
/// <summary>Tweens a RectTransform's anchoredPosition3D to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOAnchorPos3D(this RectTransform target, Vector3 endValue, float duration, bool snapping = false) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, endValue, duration); t.SetOptions(snapping).SetTarget(target); return(t); }
/// <summary>Tweens a RectTransform's anchoredPosition3D Z to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOAnchorPos3DZ(this RectTransform target, float endValue, float duration, bool snapping = false) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.anchoredPosition3D, x => target.anchoredPosition3D = x, new Vector3(0, 0, endValue), duration); t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); return(t); }
/// <summary>Tweens a RectTransform's sizeDelta to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOSizeDelta(this RectTransform target, Vector2 endValue, float duration, bool snapping = false) { TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.sizeDelta, x => target.sizeDelta = x, endValue, duration); t.SetOptions(snapping).SetTarget(target); return(t); }
/// <summary>Tweens a Slider's value to the given value. /// Also stores the Slider as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <float, float, FloatOptions> DOValue(this Slider target, float endValue, float duration, bool snapping = false) { TweenerCore <float, float, FloatOptions> t = DOTween.To(() => target.value, x => target.value = x, endValue, duration); t.SetOptions(snapping).SetTarget(target); return(t); }
/// <summary>Tweens a Rigidbody's Z position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOMoveZ(this Rigidbody target, float endValue, float duration, bool snapping = false) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector3(0, 0, endValue), duration); t.SetOptions(AxisConstraint.Z, snapping).SetTarget(target); return(t); }
/// <summary>Tweens a RectTransform's pivot Y to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOPivotY(this RectTransform target, float endValue, float duration) { TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.pivot, x => target.pivot = x, new Vector2(0, endValue), duration); t.SetOptions(AxisConstraint.Y).SetTarget(target); return(t); }
/// <summary>Tweens a Rigidbody's position to the given value. /// Also stores the rigidbody as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOMove(this Rigidbody target, Vector3 endValue, float duration, bool snapping = false) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, endValue, duration); t.SetOptions(snapping).SetTarget(target); return(t); }
/// <summary>Tweens a RectTransform's anchoredPosition X to the given value. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOAnchorPosX(this RectTransform target, float endValue, float duration, bool snapping = false) { TweenerCore <Vector2, Vector2, VectorOptions> t = DG.Tweening.DOTween.To(() => target.anchoredPosition, x => target.anchoredPosition = x, new Vector2(endValue, 0), duration); t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); return(t); }
/// <summary>Tweens a 2D Toolkit TextMesh's dimensions to the given value. /// Also stores the TextMesh as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOScaleX(this tk2dTextMesh target, float endValue, float duration) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(endValue, 0, 0), duration); t.SetOptions(AxisConstraint.X) .SetTarget(target); return(t); }
/// <summary>Tweens a Sprite's dimensions to the given value. /// Also stores the Sprite as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector3, Vector3, VectorOptions> DOScaleZ(this tk2dBaseSprite target, float endValue, float duration) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To(() => target.scale, x => target.scale = x, new Vector3(0, 0, endValue), duration); t.SetOptions(AxisConstraint.Z) .SetTarget(target); return(t); }
/// <summary>Tweens a Text's text to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end string to tween to</param><param name="duration">The duration of the tween</param> /// <param name="richTextEnabled">If TRUE (default), rich text will be interpreted correctly while animated, /// otherwise all tags will be considered as normal text</param> /// <param name="scrambleMode">The type of scramble mode to use, if any</param> /// <param name="scrambleChars">A string containing the characters to use for scrambling. /// Use as many characters as possible (minimum 10) because DOTween uses a fast scramble mode which gives better results with more characters. /// Leave it to NULL (default) to use default ones</param> public static TweenerCore <string, string, StringOptions> DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null) { TweenerCore <string, string, StringOptions> t = DOTween.To(() => target.text, x => target.text = x, endValue, duration); t.SetOptions(richTextEnabled, scrambleMode, scrambleChars) .SetTarget(target); return(t); }
/// <summary>Tweens a SlicedSprite's dimensions to the given value. /// Also stores the SlicedSprite as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOScaleDimensionsY(this tk2dSlicedSprite target, float endValue, float duration) { TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.dimensions, x => target.dimensions = x, new Vector2(0, endValue), duration); t.SetOptions(AxisConstraint.Y) .SetTarget(target); return(t); }
public override bool CreateTween(GameObject target, float duration, int loops, LoopType loopType) { TweenerCore <Vector3, Vector3, VectorOptions> scaleTween = target.transform.DOScale(scale, duration).SetEase(ease); scaleTween.SetOptions(axisConstraint); SetTween(scaleTween, loops, loopType); return(true); }
/// <summary>Tweens an LayoutElement's preferredWidth/Height to the given value. /// Also stores the LayoutElement as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector2, Vector2, VectorOptions> DOPreferredSize(this LayoutElement target, Vector2 endValue, float duration, bool snapping = false) { TweenerCore <Vector2, Vector2, VectorOptions> t = DOTween.To(() => new Vector2(target.preferredWidth, target.preferredHeight), x => { target.preferredWidth = x.x; target.preferredHeight = x.y; }, endValue, duration); t.SetOptions(snapping).SetTarget(target); return(t); }
/// <summary>Tweens a RectTransform's anchoredPosition so that it draws a circle around the given center. /// Also stores the RectTransform as the tween's target so it can be used for filtered operations.<para/> /// IMPORTANT: SetFrom(value) requires a <see cref="Vector2"/> instead of a float, where the X property represents the "from degrees value"</summary> /// <param name="center">Circle-center/pivot around which to rotate (in UI anchoredPosition coordinates)</param> /// <param name="endValueDegrees">The end value degrees to reach (to rotate counter-clockwise pass a negative value)</param> /// <param name="duration">The duration of the tween</param> /// <param name="relativeCenter">If TRUE the <see cref="center"/> coordinates will be considered as relative to the target's current anchoredPosition</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore <Vector2, Vector2, CircleOptions> DOShapeCircle( this RectTransform target, Vector2 center, float endValueDegrees, float duration, bool relativeCenter = false, bool snapping = false ) { TweenerCore <Vector2, Vector2, CircleOptions> t = DOTween.To( CirclePlugin.Get(), () => target.anchoredPosition, x => target.anchoredPosition = x, center, duration ); t.SetOptions(endValueDegrees, relativeCenter, snapping).SetTarget(target); return(t); }
private void Move(Vector2 point) { var position = (Vector2)_transform.position; var distance = Vector2.Distance(position, point); _tweens.Add(DOMove);//_transform.DOMove(point, distance / 2f).SetEase(Ease.InOutCubic)); Tween DOMove(Transform target) { TweenerCore <Vector3, Vector3, VectorOptions> t = DOTween.To((DOGetter <Vector3>)(() => target.position), (DOSetter <Vector3>)(x => target.position = x), point, distance / 2f); t.SetOptions(false).SetTarget <Tweener>((object)target); return(t); } }
/// <summary>Tweens a Text's text to the given value. /// Also stores the Text as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end string to tween to</param><param name="duration">The duration of the tween</param> /// <param name="richTextEnabled">If TRUE (default), rich text will be interpreted correctly while animated, /// otherwise all tags will be considered as normal text</param> /// <param name="scrambleMode">The type of scramble mode to use, if any</param> /// <param name="scrambleChars">A string containing the characters to use for scrambling. /// Use as many characters as possible (minimum 10) because DOTween uses a fast scramble mode which gives better results with more characters. /// Leave it to NULL (default) to use default ones</param> public static TweenerCore <string, string, StringOptions> DOText(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null) { if (endValue == null) { if (Debugger.logPriority > 0) { Debugger.LogWarning("You can't pass a NULL string to DOText: an empty string will be used instead to avoid errors"); } endValue = ""; } TweenerCore <string, string, StringOptions> t = DOTween.To(() => target.text, x => target.text = x, endValue, duration); t.SetOptions(richTextEnabled, scrambleMode, scrambleChars) .SetTarget(target); return(t); }
public override bool CreateTween(GameObject target, float duration, int loops, LoopType loopType) { RectTransform rectTransform = target.transform as RectTransform; if (rectTransform == null) { Debug.LogError($"{target} does not have {TargetComponentType} component"); return(false); } TweenerCore <Vector2, Vector2, VectorOptions> anchorPosTween = rectTransform.DOAnchorPos(GetPosition(), duration); anchorPosTween.SetOptions(axisConstraint); SetTween(anchorPosTween, loops, loopType); return(true); }
/// <summary>Tweens a Rigidbody2D's X position to the given value. /// Also stores the Rigidbody2D as the tween's target so it can be used for filtered operations</summary> /// <param name="endValue">The end value to reach</param><param name="duration">The duration of the tween</param> /// <param name="snapping">If TRUE the tween will smoothly snap all values to integers</param> public static TweenerCore<Vector2, Vector2, VectorOptions> DOMoveX(this Rigidbody2D target, float endValue, float duration, bool snapping = false) { TweenerCore<Vector2, Vector2, VectorOptions> t = DOTween.To(() => target.position, target.MovePosition, new Vector2(endValue, 0), duration); t.SetOptions(AxisConstraint.X, snapping).SetTarget(target); return t; }
public static TweenerCore <string, string, StringOptions> DOTextAlign(this Text target, string endValue, float duration, bool richTextEnabled = true, ScrambleMode scrambleMode = ScrambleMode.None, string scrambleChars = null) { if (endValue == null) { if (Debugger.logPriority > 0) { Debugger.LogWarning("You can't pass a NULL string to DOText: an empty string will be used instead to avoid errors"); } endValue = ""; } bool isRich = false; for (ushort index = 0; index < endValue.Length; index++) { if (endValue[index] == '<') { isRich = true; SetDoTextRichIndex(index, endValue); break; } } TweenerCore <string, string, StringOptions> t = DOTween.To( () => target.text, (x) => { m_doTextCache.Clear(); m_doTextCache.Append(x); m_doTextCache.Append("<color=#00000000>"); bool isEqual = true; ushort richEndLength = 0; if (isRich) { for (ushort index = 0; index < x.Length; index++) { if (x[index] != endValue[index]) { isEqual = false; } if (!isEqual) { richEndLength++; } } } if (isEqual) { for (int index = x.Length; index < endValue.Length; index++) { m_doTextCache.Append(endValue[index]); } } else { ushort startIndex = Convert.ToUInt16(x.Length - richEndLength); string[] richEndList = m_doTextIndexRichStart[startIndex]; if (m_doTextIndexRichStart.ContainsKey(startIndex)) { for (short arrayIndex = Convert.ToInt16(richEndList.Length - 1); arrayIndex >= 0; arrayIndex--) { m_doTextCache.Append(richEndList[arrayIndex]); } } for (int index = startIndex; index < endValue.Length; index++) { m_doTextCache.Append(endValue[index]); } } m_doTextCache.Append("</color>"); target.text = m_doTextCache.ToString(); }, endValue, duration ); t.SetOptions(richTextEnabled, scrambleMode, scrambleChars) .SetTarget(target); return(t); }
public static TweenerCore <Vector3, Path, PathOptions> SetOptions(this TweenerCore <Vector3, Path, PathOptions> t, AxisConstraint lockPosition, AxisConstraint lockRotation = AxisConstraint.None) { return(t.SetOptions(false, lockPosition, lockRotation)); }