概要
2018/2/9 に「CoroutineChain」がリリースされました
「CoroutineChain」を導入すると、
コルーチンを連結できるようになります
検証環境
- Unity 2017.3.0f3
- CoroutineChain 0.1.1
使用例
using System.Collections; using UnityEngine; public class Example : MonoBehaviour { private IEnumerator Start() { var time = 1f; while ( true ) { yield return CoroutineChain.Start .Play( MoveToForSec( Vector3.up, time ) ) .Wait( time ) .Play( MoveToForSec( Vector3.zero, time ) ) .Wait( time ) .Play( MoveToForSec( Vector2.one, time ) ) .Wait( time ) .Play( MoveToForSec( Vector3.right, time ) ) .Wait( time ) .Parallel( MoveToForSec( Vector3.up, time ), MoveToForSec( Vector2.one, time ) ) .Log( "Parallel 完了" ) .Wait( time ) .Sequential( MoveToForSec( Vector3.zero, time ), MoveToForSec( Vector3.right, time ) ) .Log( "Sequential 完了" ) .Wait( time ) .Call( () => print( "完了" ) ) ; } } private IEnumerator MoveToForSec( Vector3 pos, float time ) { yield return new WaitForSeconds( time ); } }