Script Execution Order 설정을 사용하면 Unity가 다른 MonoBehaviour 클래스의 이벤트 함수를 호출하는 상대 순서를 지정할 수 있습니다. 예를 들어 Unity가 MoveForward
MonoBehaviour 스크립트를 실행하기 전에 Rotation
MonoBehaviour 스크립트의 이벤트 함수를 실행하도록 지정할 수 있습니다.
이러한 순서는 이벤트 함수의 각 카테고리에 개별적으로 적용되므로, Unity는 지정된 순서로 프레임 동안 호출해야 하는 Awake 함수를 호출한 후 나중에 동일한 순서로 활성 게임 오브젝트의 Update 함수를 호출합니다.
프로젝트 설정 인스펙터에서 스크립트 실행 순서를 조정할 수 있습니다. 메뉴에서 Edit > Project Settings 로 이동한 후 Script Execution Order 카테고리를 선택하십시오.
참고: 여러 게임 오브젝트에 여러 스크립트 타입을 할당하는 경우 스크립트 실행 순서는 연결된 게임 오브젝트에 관계없이 한 가지 타입의 모든 스크립트가 다른 타입의 모든 스크립트보다 먼저 실행되도록 지정합니다.
더하기(+) 버튼을 사용하여 설정 인스펙터 창에 스크립트를 추가하고 클래스명을 선택할 수 있습니다. 스크립트를 제거하려면 리스트의 각 항목 오른쪽에 있는 빼기(-) 버튼을 사용하십시오.
실행 순서를 지정하려면 리스트의 항목을 원하는 위치로 드래그하거나 리스트에서 클래스의 순서 번호를 편집하십시오. 할당된 번호는 상대 순서를 나타냅니다. Unity는 위에서 아래로(음수 순서가 더 높은 스크립트부터 양수 순서가 더 높은 스크립트까지) 리스트를 실행합니다. Unity는 Default Time 슬롯 동안 리스트에 없는 모든 스크립트를 실행합니다. 이 작업은 음수 순서 번호가 있는 스크립트 다음에, 그리고 양수 순서 번호가 있는 스크립트 이전에 발생합니다.
순서 번호는 임의적이고 물리적 수량을 나타내지 않습니다. 에디터는 이러한 값을 스크립트 메타데이터 파일에 저장합니다. 리스트에서 다른 스크립트를 추가하거나 이동시킬 때 불필요한 파일 변경을 방지하기 위해 순서 번호 사이에 간격을 둘 수 있습니다.
참고: 이 설정 창에서 지정된 실행 순서는 RuntimeInitializeOnLoadMethod 속성으로 표시된 함수 순서에 영향을 주지 않습니다(런타임 초기화 순서는 지정할 수 없음).
Unity가 프레임에서 이벤트 함수의 다양한 카테고리를 각각 호출하는 시기에 대한 내용은 이벤트 함수 실행 순서를 참조하십시오.
MonoManager
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.