일반적인 멀티플레이어 게임 작동 중에 발생할 수 있는 호스트 시작, 플레이어 참여 또는 플레이어 퇴장 같은 여러 이벤트가 있습니다. 이런 가능한 이벤트에는 각각 이벤트가 발생하면 조치를 취하기 위해 사용자 지정 코드에서 구현할 수 있는 관련 콜백이 있습니다.
네트워크 관리자에 대해 이 작업을 수행하려면 NetworkManager로부터 상속하는 사용자 지정 스크립트를 작성해야 합니다. 그런 다음 NetworkManager의 가상 메서드를 특정 이벤트 발생 시에 취할 조치의 사용자 지정 구현으로 오버라이드할 수 있습니다.
이 페이지에는 네트워크 관리자에서 구현할 수 있는 모든 가상 메서드(콜백)와 각각이 발생하는 시기가 나열되어 있습니다. 발생하는 콜백과 콜백이 발생하는 시기는 LAN 모드 또는 인터넷(매치메이커) 모드 중 게임이 실행되는 모드에 따라 약간 다르므로 아래에는 각 모드의 콜백이 별도로 명시되어 있습니다.
게임이 LAN(로컬 영역 연결)에서 실행 중인 경우에 발생하는 콜백입니다. 게임은 host, client 또는 server-only 중 한 가지 모드에서 실행될 수 있습니다. 아래에는 각 모드의 콜백이 나열되어 있습니다.
호스트 시작 시:
Start()
함수 호출됨
OnStartHost
OnStartServer
OnServerConnect
OnStartClient
OnClientConnect
OnServerSceneChanged
OnServerReady
OnServerAddPlayer
OnClientSceneChanged
클라이언트 연결 시:
OnServerConnect
OnServerReady
OnServerAddPlayer
클라이언트 연결 해제 시:
OnServerDisconnect
호스트 중지 시:
OnStopHost
OnStopServer
OnStopClient
클라이언트 시작 시:
Start()
함수 호출됨
OnStartClient
OnClientConnect
OnClientSceneChanged
클라이언트 중지 시:
OnStopClient
OnClientDisconnect
서버 시작 시:
Start()
함수 호출됨
OnStartServer
OnServerSceneChanged
클라이언트 연결 시:
OnServerConnect
OnServerReady
OnServerAddPlayer
클라이언트 연결 해제 시:
OnServerDisconnect
서버 중지 시:
OnStopServer
게임이 인터넷 모드에서 실행 중인 경우(즉 매치메이커 서비스를 사용하여 다른 플레이어를 찾고 서로 연결하는 경우)에 발생하는 콜백입니다. 이 모드에서는 게임이 두 가지 모드인 host 또는 client 중 하나에서 실행될 수 있습니다. 아래에는 각 모드의 콜백이 나열되어 있습니다.
호스트 시작 시:
Start()
함수 호출됨
OnStartHost
OnStartServer
OnServerConnect
OnStartClient
OnMatchCreate
OnClientConnect
OnServerSceneChanged
OnServerReady
OnServerAddPlayer
OnClientSceneChanged
클라이언트 연결 시:
OnServerConnect
OnServerReady
OnServerAddPlayer
클라이언트 연결 해제 시:
OnServerDisconnect
온라인 게임 인스턴스 리스트 수신 시:
Start()
함수 호출됨
OnMatchList
매치 참여 시:
OnStartClient
OnMatchJoined
OnClientConnect
OnClientSceneChanged
호스트 중지 시:
OnStopClient
OnClientDisconnect
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.