참고: UNet은 지원이 중단되었으며 향후 Unity에서 삭제될 예정입니다. 현재 새로운 시스템이 개발 중입니다. 자세한 내용과 다음 단계는 이 블로그 포스트와 FAQ를 참조하십시오. |
멀티플레이어 게임을 만들 때에는 네트워크로 연결된 게임 오브젝트의 프로퍼티 동기화 외에도 다른 정보를 보내고 받거나 다른 정보에 응답해야 합니다. 예를 들어, 매치 시작 시간, 플레이어의 매치 참가 또는 퇴장 여부, 또는 게임 타입별 기타 정보(예: “깃발 탈취” 게임에서 깃발이 탈취되었다는 알림을 모든 플레이어에게 전송)가 여기에 해당합니다.
Unity 네트워킹 고수준 API 내에서는 크게 세 가지 방식으로 이러한 타입의 정보를 주고받을 수 있습니다.
원격 액션을 통해 네트워크 전체에서 스크립트의 메서드를 호출할 수 있습니다. 서버가 모든 클라이언트 또는 특정한 개별 클라이언트의 메서드를 호출하도록 만들 수 있습니다. 또한 클라이언트가 서버의 메서드를 호출하도록 만들 수도 있습니다. 원격 액션을 사용하면 로컬(비 멀티플레이어) 프로젝트에서 메서드를 호출하는 것과 매우 유사한 방식으로 데이터를 메서드에 파라미터로 전달할 수 있습니다.
네트워킹 콜백을 이용하면 게임 중에 발생하는 빌트인 Unity 이벤트에 연결할 수 있습니다. 예를 들어, 플레이어가 참가 또는 퇴장하는 경우, 게임 오브젝트가 생성되거나 삭제되는 경우, 새로운 씬이 로드되는 경우가 여기에 해당합니다. 구현할 수 있는 네트워크 콜백에는 다음의 두 가지 타입이 있습니다.
네트워크 관리자 콜백 - 네트워크 관리자 자체와 관련된 콜백(예: 클라이언트가 연결 또는 연결 해제되는 경우)
네트워크 동작 콜백 - 네트워크로 연결된 개별 게임 오브젝트와 관련된 콜백(Start 함수가 호출되는 경우, 또는 새 플레이어가 게임에 참가할 때 이러한 특정 게임 오브젝트가 수행해야 하는 작업)
네트워크 메시지는 메시지 전송에 대한 “저수준” 접근 방식입니다(아직은 네트워킹 “고수준 API”의 일부로 분류됨). 네트워크 메시지를 이용하면 스크립팅을 통해 클라이언트와 서버 간에 데이터를 직접 전송할 수 있습니다. 기본 타입의 데이터(int, string 등)뿐만 아니라 가장 일반적인 Unity 타입(예: Vector3)도 전송할 수 있습니다. 이러한 작업은 사용자가 직접 구현하는 것이기 때문에 이 메시지는 어떠한 특정 게임 오브젝트 또는 Unity 이벤트에도 직접 연결되지 않습니다. 메시지의 목적 및 구현 여부는 사용자의 선택에 달렸습니다.
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.