YuminekoGame
7/18/2019 - 2:01 PM

DOVirtual Delay

using DG.Tweening;
using UnityEngine;

public class Delay : MonoBehaviour {
    Tween doTween;

    //  1秒後に実行
    public void DelayAction () {
        doTween = DOVirtual.DelayedCall (1f, () => DoSomething ());
    }

    //  キャンセルする(DoSomethingは呼ばれない)
    public void Cancel () {
        doTween.Kill ();
    }

    //  待機をやめて即座に実行する
    public void Immediate () {
        doTween.Complete (true);
    }

    void DoSomething () {
        Debug.Log ("処理");
    }
}