All Articles

Graphics/Unity

DOTween Sequence 분리하기

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

public class SequenceBase
{
    protected bool isCompleted;
    protected bool isSuccessed;

    public event Action Completed;

    protected bool IsCompleted
    {
        get => isCompleted;
        set
        {
            isCompleted = value;
            OnCompleted();
        }
    }

    protected bool IsSuccessed
    {
        get => isSuccessed;
        set => isSuccessed = value;
    }

    public void OnCompleted()
    {
        if (Completed != null && IsCompleted == true)
        {
            Completed();
        }
    }

    public IEnumerator StartSequence()
    {
        Sequence sequence = DOTween.Sequence();
        sequence.OnComplete(() => IsCompleted = true);

        yield return WaitForCompletion();
    }

    public IEnumerator WaitForCompletion()
    {
        while (!IsCompleted)
        {
            yield return Task.Yield();
        }

        yield return null;
    }

}

'Graphics > Unity' 카테고리의 다른 글

Unity GRPC  (0) 2022.01.17
[Unity] 한글 폰트 적용 - NotoSansKR  (0) 2021.10.10
[MRTK] Custom Hand Input to MRTK TrackedHandJoint  (0) 2021.09.14