以下の内容はhttps://baba-s.hatenablog.com/entry/2017/12/26/210100より取得しました。


【Unity】時限式のコールバックを実装できる「TeaTime」紹介

はじめに

「TeaTime」を Unity プロジェクトに導入することで
時限式のコールバックを実装できるようになります

使用例

using matnesis.TeaTime;
using UnityEngine;

public class Example : MonoBehaviour
{
    private void Awake()
    {
        // 2 秒後に実行
        this
            .tt()
            .Add( 2, () => Debug.Log( "ピカチュウ" ) )
        ;

        // 3 秒毎に繰り返す
        this.tt()
            .Add( () => Debug.Log( "ピカチュウ" ) )
            .Add( 3 )
            .Repeat()
        ;
        
        // 1.5 秒間繰り返す
        this
            .tt()
            .Loop( 1.5f, _ => Debug.Log( "ピカチュウ" ) )
        ;

        // 自動実行を無効化
        var somethingForLater = this
            .tt()
            .Pause()
            .Add( 3, () => Debug.Log( "ピカチュウ" ) )
        ;

        somethingForLater.Play();

        // Tween ライブラリのように使用
        this
            .tt()
            .Add( () =>
            {
                transform.position = new Vector3( 999, 999, 999 );
            } )
            .Loop( 4, loop =>
            {
                transform.position = Vector3.Lerp
                (
                    transform.position,
                    Vector3.zero,
                    loop.deltaTime
                );
            } )
            .Add( () => Debug.Log( "ピカチュウ" ) )
        ;
    }
}

関連記事




以上の内容はhttps://baba-s.hatenablog.com/entry/2017/12/26/210100より取得しました。
このページはhttp://font.textar.tv/のウェブフォントを使用してます

不具合報告/要望等はこちらへお願いします。
モバイルやる夫Viewer Ver0.14