네트워크 관리자 콜백처럼 일반적인 멀티플레이어 게임 도중에 발생할 수 있는 네트워크 동작과 관련된 호스트 시작, 플레이어 참여 또는 플레이어 퇴장 같은 여러 이벤트가 있습니다. 이런 가능한 이벤트에는 각각 이벤트가 발생하면 조치를 취하기 위해 사용자 지정 코드에서 구현할 수 있는 관련 콜백이 있습니다.
NetworkBehaviour로부터 상속하는 스크립트를 작성하면 이런 이벤트가 발생할 때 취할 조치의 사용자 지정 구현을 작성할 수 있습니다. 이렇게 하려면 NetworkBehaviour
클래스의 가상 메서드를 특정 이벤트가 발생할 경우에 취할 조치의 사용자 지정 구현으로 오버라이드합니다.
이 페이지에는 Network Behaviour에 대해 구현할 수 있는 모든 가상 메서드(콜백)와 각각이 발생하는 시기가 나열되어 있습니다. 게임은 세 가지 모드인 host, client, 또는 server-only 중 하나에서 실행될 수 있습니다. 각 모드의 콜백은 아래에 나열되어 있습니다.
클라이언트 연결 시:
OnStartServer
OnRebuildObservers
Start()
함수 호출됨
클라이언트 연결 시:
OnStartClient
OnStartLocalPlayer
OnStartAuthority
Start()
함수 호출됨
다음은 클라이언트 연결 시에 플레이어 게임 오브젝트에서만 호출됩니다.
OnStartServer
OnStartClient
OnRebuildObservers
OnStartAuthority
OnStartLocalPlayer
Start()
함수 호출됨
OnSetLocalVisibility
나머지 클라이언트에서 클라이언트 연결이 끊길 때:
OnNetworkDestroy
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.