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)

All DEV content is created by the community!

Hey, if you're landing here for the first time, you should know that this website is a global community of folks who blog about their experiences to help folks like you out.

Sign up now if you're curious. It's free!