Version: 2021.3
언어: 한국어
Unity 스탠드얼론 플레이어 커맨드 라인 인자
텍스트 기반 씬 파일

배치 모드 및 빌트인 코루틴 호환성

이 페이지에서는 배치 모드에서 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

예제 코루틴 스크립트

AsyncOperation

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");
    }
}

WaitForEndOfFrame

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");
    }
}

WaitForFixedUpdate

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");
    }
}

WaitForSeconds

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");
    }
}

WaitForSecondsRealtime

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");
    }
}

WaitUntil

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");
    }
}

WaitWhile

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에서 배치 모드 및 코루틴 사용에 관한 팁 추가됨

Unity 스탠드얼론 플레이어 커맨드 라인 인자
텍스트 기반 씬 파일
Copyright © 2023 Unity Technologies
优美缔软件(上海)有限公司 版权所有
"Unity"、Unity 徽标及其他 Unity 商标是 Unity Technologies 或其附属机构在美国及其他地区的商标或注册商标。其他名称或品牌是其各自所有者的商标。
公安部备案号:
31010902002961