---
title: Yield 命令リファレンス
product: Unity Editor
version: '6000.0'
latest_version: '7000.0'
status: This page documents version 6000.0. The latest version is 7000.0.
canonical: https://docs.unity.com/ja-jp/engine/6000.0/manual/scripting/object-oriented-development/coroutines-section/coroutines-yield-instructions
latest_url: https://docs.unity.com/ja-jp/engine/7000.0/manual/scripting/object-oriented-development/coroutines-section/coroutines-yield-instructions.md
generated_at: 2026-11-14T02:13:20.133Z
locale: ja-jp
---

# Yield 命令リファレンス

> コルーチンメソッドで異なるカスタム命令を実行して、再開するタイミングをコントロールします。

コルーチンは、`yield return`ステートメントで実行をサスペンドします。`yield return null`は、次のフレームまでコルーチンの実行を一時停止します。ただし、`yield return`は Unity エディターやランタイムに、例えば指定された時間だけ待機したり、条件が満たされるまでコルーチンの実行を再開するように指示を返すこともできます。

## ランタイム yield 命令##runtime-yield-instructions

Unity には、[`UnityEngine.YieldInstruction`](/engine/6000.0/script-reference/unityengine/yieldinstruction.md) から派生したカスタムの yield 命令のセットがあり、指定した時間が経過した後、指定した条件が満たされたとき、またはプレイヤーループの特定の時点で再開するために使用できます。

| 指示                                                                                                | 説明                                                                                                                                                              |
| ------------------------------------------------------------------------------------------------- | --------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| [`AsyncOperation`](/engine/6000.0/script-reference/unityengine/asyncoperation.md)                 | コルーチンを中断し、シーンやアセットの読み込みなどの非同期操作が完了したときに再開します。                                                                                                                   |
| [`WaitForEndOfFrame`](/engine/6000.0/script-reference/unityengine/waitforendofframe.md)           | コルーチンを中断し、すべてのレンダリングと GUI イベントの後のフレームの終了時に再開します。**注**： エディターがバッチモードのとき、スクリプトに`[ExecuteInEditMode]`や`[ExecuteAlways]`マークがあっても、`WaitForEndOfFrame`は編集モードで実行されません。 |
| [`WaitForFixedUpdate`](/engine/6000.0/script-reference/unityengine/waitforfixedupdate.md)         | コルーチンを中断し、 すべての物理演算後の次の物理演算更新の終了時に再開します 。                                                                                                                       |
| [`WaitForSeconds`](/engine/6000.0/script-reference/unityengine/waitforseconds.md)                 | コルーチンを中断し、タイムスケールをアカウントして指定された秒数が経過した後に再開します。                                                                                                                   |
| [`WaitForSecondsRealtime`](/engine/6000.0/script-reference/unityengine/waitforsecondsrealtime.md) | コルーチンを中断し、指定された秒数が経過した後にタイムスケールを無視して再開します。                                                                                                                      |
| [`WaitUntil`](/engine/6000.0/script-reference/unityengine/waituntil.md)                           | コルーチンを中断し、指定されたデリゲートが`true`を評価すると再開します。                                                                                                                         |
| [`WaitWhile`](/engine/6000.0/script-reference/unityengine/waitwhile.md)                           | コルーチンを中断し、指定されたデリゲートが`false`を評価すると再開します。                                                                                                                        |

これらの yield 命令の詳細と使用例については、API リファレンスのページを参照してください。

プレイヤーループで異なるコルーチンが再開される場所を視覚的に示すには、[イベント機能実行順](/engine/6000.0/manual/scripting/object-oriented-development/managing-update-order/execution-order.md)の図を参照してください。

## UnityTest yield 命令##unitytest-yield-instructions

`[UnityTest]` 属性でマークされた Unity Test Framework テストは、コルーチンとして実行されます。Test Framework パッケージは、Unity エディターをテストからコントロールするための追加の yield 命令のサポートを追加し、カスタム yield 命令を定義する機能を提供します。

| 指示                                                                                                                                                                  | 説明                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------- | ----------------------------------------- |
| [`EnterPlayMode`](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/api/UnityEngine.TestTools.EnterPlayMode.html)             | Unity エディターが再生モードに入るための yield 命令を作成します。   |
| [`ExitPlayMode`](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/api/UnityEngine.TestTools.ExitPlayMode.html)               | Unity エディターが再生モードを終了するための yield 命令を作成します。 |
| [`RecompileScripts`](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/api/UnityEngine.TestTools.RecompileScripts.html)       | Unity エディターでスクリプトの再コンパイルをトリガーします。         |
| [`WaitForDomainReload`](https://docs.unity3d.com/Packages/com.unity.test-framework@latest/index.html?subfolder=/api/UnityEngine.TestTools.WaitForDomainReload.html) | 受信ドメインのリロード後までスクリプトの実行を遅らせます。             |

Unity Test Framework が提供する収率命令の詳細は、[エディタの収率命令](/engine/6000.0/manual/reference-custom-yield-instructions.md) を参照してください。

## エディターの yield 命令##editor-yield-instructions

Editor Coroutines パッケージは、Unity エディターの編集モードで実行されるコルーチンのサポートを追加します。パッケージには、編集モードコルーチンの追加の yield 命令が含まれています。

| 指示                                                                                                                                                                              | 説明                                                        |
| ------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- | --------------------------------------------------------- |
| [`EditorWaitForSeconds`](https://docs.unity3d.com/Packages/com.unity.editorcoroutines@latest/index.html?subfolder=/api/Unity.EditorCoroutines.Editor.EditorWaitForSeconds.html) | アカウントのタイムスケールを考慮して、指定された秒数が経過した後に EditorCoroutine を再開します。 |

詳細については、[Editor Coroutines](https://docs.unity3d.com/Packages/com.unity.editorcoroutines@latest) を参照してください。

## バッチモードのサポート##batch-mode-support

スタンドアロン [プレイヤーをバッチ モード](/engine/6000.0/manual/unity-editor/command-line-arguments/player.md)で実行する場合、ランタイム コルーチン yield 命令はすべて法線として実行されます。

[バッチモードでエディタ](/engine/6000.0/manual/unity-editor/command-line-arguments/editor.md#batchmode)を実行し、プロジェクトに[`[ExecuteInEditMode]`また](/engine/6000.0/script-reference/unityengine/executeineditmode.md)は[`[ExecuteAlways]`](/engine/6000.0/script-reference/unityengine/executealways.md)マークが付けられ、編集モードでも実行されるスクリプトがある場合、`WaitForEndOfFrame`を除くそれらのスクリプトのすべてのランタイムコルーチンは編集モードで実行されます。これは、すべての Unity サブシステムが編集モードでランタイムほど頻繁に更新されないためです。詳細については、[`[ExecuteAlways]`](/engine/6000.0/script-reference/unityengine/executealways.md) API リファレンス を参照してください。

## 追加リソース##additional-resources

* [コマンドライン引数](/engine/6000.0/manual/unity-editor/command-line-arguments.md)
* API リファレンス
