MonoBehaviour 클래스는 기본적으로 모든 Unity 스크립트가 파생되는 기본 클래스입니다. Unity의 프로젝트 창에서 C# 스크립트를 생성하면 MonoBehaviour에서 자동으로 상속되며, 템플릿 스크립트를 제공합니다. 이에 대한 자세한 내용은 스크립트 생성 및 사용을 참조하십시오.
MonoBehaviour 클래스는 에디터에서 게임 오브젝트에 스크립트를 연결할 수 있는 프레임워크를 제공할 뿐만 아니라, 시작 및 업데이트 등과 같은 유용한 이벤트에 대한 연결을 제공합니다.
MonoBehaviour 클래스의 모든 구성원에 대한 완전한 레퍼런스와 해당 기술 세부 사항은 MonoBehaviour 스크립트 레퍼런스를 참조하십시오.
MonoBehaviour 클래스를 사용하면 코루틴을 시작, 중지 및 관리할 수 있습니다. 이는 특정 시간 동안 기다리거나 특정 작업이 완료될 때까지 기다리면서 다른 코드가 계속 실행되도록 해주는 비동기 코드 작성 방식입니다.
코루틴에 대한 자세한 내용은 코루틴 매뉴얼 페이지와 StartCoroutine 메서드 스크립트 레퍼런스를 참조하십시오.
MonoBehaviour 클래스는 대규모 이벤트 메시지 컬렉션에 대한 액세스를 제공하며, 이를 통해 현재 프로젝트에서 발생하는 상황에 따라 코드를 실행할 수 있습니다. 다음은 일반적인 몇 가지 예입니다. 전체 리스트는 MonoBehaviour 스크립트 레퍼런스 페이지의 Messages 섹션을 참조하십시오.
Start
- 게임 오브젝트가 존재하기 시작할 때 호출됩니다(씬이 로드될 때 또는 게임 오브젝트가 인스턴스화될 때 호출).
Update
- 프레임마다 호출됩니다.
FixedUpdate
- 물리 타임스텝마다 호출됩니다.
OnBecameVisible
및 OnBecameInvisible
- 게임 오브젝트의 렌더러가 카메라의 뷰에 들어오거나 나갈 때 호출됩니다.
OnCollisionEnter
및 OnTriggerEnter
- 물리 충돌 또는 트리거가 발생할 때 호출됩니다.
OnDestroy
- 게임 오브젝트가 파괴될 때 호출됩니다.
MonoBehaviour
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.