22
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 3 years have passed since last update.

UniTaskでDoTweenを使う In 2020/11

Posted at

使用バージョン

  • Unity 2020.1.1f1
  • UniTask 2.0.37

結論

UniTaskとDoTweenをプロジェクトにインポートして
BuildSettings → PlayerSettings → Playerの
Scripting Define Symbols

UNITASK_DOTWEEN_SUPPORT
を追加するだけ!
UniTask1.png

使い方

通常のUniTaskと同じようにasyncのメソッドに対してDoTweenの処理をawaitすればawaitされます

サンプルコード

using System.Collections;
using System.Collections.Generic;
using Cysharp.Threading.Tasks;
using DG.Tweening;
using UnityEngine;

public class MoveTask : MonoBehaviour
{
    // Startはasyncにできる
    async UniTask Start()
    {
        await transform.DOMoveX(1.0f, 1.0f);
        await transform.DOMoveX(-1.0f, 2.0f);
    }
}

サンプルの動作

UniTask.gif

22
3
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
22
3

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?