프로그래밍 / C++ / 언리얼

Programming/C# | Unity

[C#] Unity & Photon을 활용한 서버구축

아트성 2022. 9. 13. 17:29

# PUN

[PhotonNetwork]

포톤과 관련된 여러가지 기능을 제공 (매치메이킹 / 방 생성 / 방 접속 등등)

 

Photon Unity Networking 2: PhotonNetwork Class Reference

The main class to use the PhotonNetwork plugin. This class is static. More... static bool ConnectUsingSettings ()  Connect to Photon as configured in the PhotonServerSettings file. More...   static bool ConnectUsingSettings (AppSettings appSettings, bo

doc-api.photonengine.com

 

API

    - ConnectUsingSettings() : 매치메이킹 서버에 접속한다. (PhotonServerSettings 스크럽터블에서 여러가지 데이터 설정)

    - JoinRandomRoom() : 현재 접속 가능한 방 중 임의로 접속한다.

    - LoadLevel() : 방에 있는 모든 클라이언트를 특정 씬으로 이동시킨다.

    - CreateRoom() : 방을 생성한다.

 

 

 

[MonoBehaviourPunCallbacks]

MonoBehaviour에 PUN과 관련된 콜백 메서드 제공한다.

 

Photon Unity Networking 2: MonoBehaviourPunCallbacks Class Reference

This class provides a .photonView and all callbacks/events that PUN can call. Override the events/methods you want to use. More... This class provides a .photonView and all callbacks/events that PUN can call. Override the events/methods you want to use. By

doc-api.photonengine.com

 

[MonoBehaviourPun]

 

Photon Unity Networking 2: MonoBehaviourPun Class Reference

This class adds the property photonView, while logging a warning when your game still uses the networkView. More... Inherits MonoBehaviour. This class adds the property photonView, while logging a warning when your game still uses the networkView.

doc-api.photonengine.com

   - PhotonView 제공

   - Photonview 컴포넌트가 추가 되어 있어야함.

 

 

[PhotonView]

방에 있는 여러 게임 오브젝트 중 로컬과 리모트를 구분하고,  데이터 동기화 기능을 제공한다.

 

 

Photon Unity Networking 2: PhotonView Class Reference

A PhotonView identifies an object across the network (viewID) and configures how the controlling client updates remote instances. More... Inherits MonoBehaviour. A PhotonView identifies an object across the network (viewID) and configures how the controlli

doc-api.photonengine.com

 

 - 데이터 동기화는 [IPunObservable.OnPhotonSerializeView()]

 - [IsMine] : 프로퍼티로 로커과 리모트 구분 가능

 - 기본 제공 컴포넌트

       * PhotonTransformView : 트랜스폼 동기화 제공

       * PhotonAnimationView : Animator 동기화 제공

       * PhotonRigidbodyView : 리지드바디 동기화 제공

 

반응형