Version: 2017.1

Coroutine

class in UnityEngine

/

継承:YieldInstruction

マニュアルに切り替える

説明

MonoBehaviour.StartCoroutine でコルーチンは再帰します。このクラスのインスタンスはコルーチンを参照するために使用され、独自のプロパティーや関数は持ち合わせていません。

コルーチンは YieldInstruction が終了命令を出すまで実行を一時停止することが できる機能です。

using UnityEngine;
using System.Collections;

public class ExampleClass : MonoBehaviour { IEnumerator WaitAndPrint() { // suspend execution for 5 seconds yield return new WaitForSeconds(5); print("WaitAndPrint " + Time.time); }

IEnumerator Start() { print("Starting " + Time.time);

// Start function WaitAndPrint as a coroutine yield return StartCoroutine("WaitAndPrint"); print("Done " + Time.time); } }

継承メンバー

Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961