DEV Community

Hiromichi Yamada
Hiromichi Yamada

Posted on • Updated on

Unity Dotween snippets

  • import lib.
using DG.Tweening;
Enter fullscreen mode Exit fullscreen mode
  • Delayed Action.
DOVirtual.DelayedCall (0.5f, ()=>Foo());

DOVirtual.DelayedCall (0.5f, ()=>Debug.Log("called after 0.5 sec."));

Enter fullscreen mode Exit fullscreen mode
  • Blink UGUI Image.
Image image = this.gameObject.GetComponent<Image> ();

DOTween.ToAlpha (
    () => image.color,
    color => image.color = color,
    0.2f,  // target alpha.
    2.0f   // time.
).SetLoops (-1, LoopType.Yoyo).SetEase (Ease.InOutCirc);
Enter fullscreen mode Exit fullscreen mode
  • Infinite Loop UGUI Object.
RectTransform rt = progressObj.transform as RectTransform;
rt.DORotate (new Vector3 (0.0f, 0.0f, -360.0f), 1.0f, RotateMode.LocalAxisAdd).SetLoops (-1, LoopType.Restart).SetEase(Ease.Linear);
Enter fullscreen mode Exit fullscreen mode
  • 独自のパラメータや変数をTweenさせる (.To).
DOTween.To(
  () => GetSomeFloat(),
  (x) => SetSomeFloat(x),
  TargetSomeFloatValue,
  TweenDurationTime
);
Enter fullscreen mode Exit fullscreen mode

Top comments (0)