이 페이지에서는 배치 모드에서 Unity 에디터와 스탠드얼론 플레이어를 실행할 때 지원되는 기능을 설명합니다.
Unity를 실행할 때 다음의 빌트인 coroutine 연산자가 다음의 기능을 추가합니다.
다음 표에는 에디터와 스탠드얼론 플레이어 내부에서 그리고 -batchmode 커맨드 라인 인자를 사용하여 배치 모드에서 에디터와 스탠드얼론 플레이어를 실행할 때 Unity가 지원하는 연산자들이 나와 있습니다.
에디터 | 에디터 -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에서 배치 모드 및 코루틴 사용에 관한 팁 추가됨
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.