이 페이지에서는 배치 모드에서 Unity 에디터와 스탠드얼론 플레이어를 실행할 때 지원되는 기능을 설명합니다.
Unity를 실행할 때 다음의 빌트인 coroutine 연산자가 다음의 기능을 추가합니다.
The following table shows which of these operators Unity supports inside the Editor and Standalone Player, and when running each of them in batch mode using the -batchmode command line argument:
에디터 | 에디터 -batchmode | Unity 스탠드얼론 플레이어 | Unity 스탠드얼론 플레이어 -batchmode | |
---|---|---|---|---|
AsyncOperation |
지원 | 지원 | 지원 | 지원 |
WaitForEndOfFrame |
지원 | 미지원* | 지원 | 지원 |
WaitForFixedUpdate |
지원 | 지원 | 지원 | 지원 |
WaitForSeconds |
지원 | 지원 | 지원 | 지원 |
WaitForSecondsRealtime |
지원 | 지원 | 지원 | 지원 |
WaitUntil |
지원 | 지원 | 지원 | 지원 |
WaitWhile |
지원 | 지원 | 지원 | 지원 |
* 애니메이션, 물리, 타임라인 등이 에디터에서 오작동하는 것을 막기 위해 -batchmode
로 에디터를 실행할 때는 WaitForEndOfFrame
을 사용할 수 없습니다. 이는 WaitForEndOfFrame
을 사용할 때 Unity가 이 시스템을 업데이트하지 않기 때문입니다.
에디터에서 “Play” 버튼을 누르면 코루틴이 포함된 코드가 실행됩니다.
커맨드 라인에서 배치 모드로 에디터를 실행할 때 코루틴을 실행하려면 다음을 입력하십시오.
C:\Program Files\Unity\Editor\Unity.exe -projectPath PROJECT_PATH -batchMode
스탠드얼론 플레이어를 실행하여 코드를 실행합니다. 플레이어는 로드한 후 코루틴이 완료되기를 기다립니다.
커맨드 라인에서 배치 모드로 플레이어를 실행할 때 코루틴을 실행하려면 다음을 입력하십시오.
PATH_TO_STANDALONE_BUILD -projectPath PROJECT_PATH -batchMode
Windows의 경우:
C:\projects\myproject\builds\myproject.exe -batchMode
Mac의 경우:
~/UnityProjects/myproject/builds/myproject -batchMode
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_AsyncTests());
}
public IEnumerator Example_AsyncTests()
{
Debug.Log("Start of AsyncLoad Example");
var load = UnityEngine.Resources.LoadAsync("");
yield return load;
yield return null;
Debug.Log("End of AsyncLoad Example");
}
}
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_WaitForEndOfFrame_Coroutine());
}
public IEnumerator Example_WaitForEndOfFrame_Coroutine()
{
Debug.Log("Start of WaitForEndOfFrame Example");
yield return new WaitForEndOfFrame();
Debug.Log("End of WaitForEndOfFrame Example");
}
}
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_WaitForFixedUpdate_Coroutine());
}
public IEnumerator Example_WaitForFixedUpdate_Coroutine()
{
Debug.Log("Start of WaitForFixedUpdate Example");
yield return new WaitForFixedUpdate();
Debug.Log("End of WaitForFixedUpdate Example");
}
}
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_WaitForSeconds_Coroutine());
}
public IEnumerator Example_WaitForSeconds_Coroutine()
{
Debug.Log("Start of WaitForSeconds Example");
yield return new WaitForSeconds(1.5f);
Debug.Log("End of WaitForSeconds Example");
}
}
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_WaitForSecondsRealtime_Coroutine());
}
public IEnumerator Example_WaitForSecondsRealtime_Coroutine()
{
Debug.Log("Start of WaitForSecondsRealtime Example");
yield return new WaitForSecondsRealtime(1.5f);
Debug.Log("End of WaitForSecondsRealtime Example");
}
}
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_WaitUntil_Coroutine());
}
public IEnumerator Example_WaitUntil_Coroutine()
{
Debug.Log("Start of WaitUntil Example");
yield return new WaitUntil(() => Time.time > 5.0f);
Debug.Log("End of WaitUntil Example");
}
}
using System.Collections;
using UnityEngine;
[ExecuteInEditMode]
public class ExampleClass : MonoBehaviour
{
public void Start()
{
StartCoroutine(Example_WaitWhile_Coroutine());
}
public IEnumerator Example_WaitWhile_Coroutine()
{
Debug.Log("Start of WaitWhile Example");
yield return new WaitWhile(() => Time.time < 5.0f);
Debug.Log("End of WaitWhile Example");
}
}
2018–06–06 페이지 게시됨
Unity 2017.4에서 배치 모드 및 코루틴 사용에 관한 팁 추가됨