Qiita Teams that are logged in
You are not logged in to any team

Log in to Qiita Team
Community
OrganizationEventAdvent CalendarQiitadon (β)
Service
Qiita JobsQiita ZineQiita Blog
2
Help us understand the problem. What are the problem?

More than 1 year has passed since last update.

Organization

UniTaskでDoTweenを使う In 2020/11

使用バージョン

  • 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

Why not register and get more from Qiita?
  1. We will deliver articles that match you
    By following users and tags, you can catch up information on technical fields that you are interested in as a whole
  2. you can read useful information later efficiently
    By "stocking" the articles you like, you can search right away
2
Help us understand the problem. What are the problem?