あなたの世界を作りなさい
スクリプティング
コルーチン
1分
コルーチンは、実行を一時停止し、停止した場所から再開することで動作する、非プリエンプティブなマルチタスクプログラムコンポーネントです。主に、非同期操作、例外、イベントループ、イテレータ、無限リスト、およびパイプなどの機能を実行するために使用されます。 unityのコルーチンについて詳しく学ぶには、ここをクリックしてください。 📘 コルーチン https //docs unity3d com/kr/current/manual/coroutines html https //docs unity3d com/kr/current/manual/coroutines html unityコルーチンのzepetoscript実装は以下の通りです。 import { zepetoscriptbehaviour } from 'zepeto script'; import { waitforseconds } from 'unityengine'; export default class coroutine extends zepetoscriptbehaviour { private current number; start() { this current = 0; console log(`ルーチンを開始`); this startcoroutine(this doroutine()); } doroutine() { while(true) { yield null; console log(`\[${this current++}] 次のルーチンを待っています `); yield new waitforseconds(1); } } } 以下のテストコード出力画面を確認してください。