반응형
- 코드 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
public class NetworkManager : MonoBehaviourPunCallbacks
{
public Text notionText;
public PhotonView PV;
private void Awake()
{
PV = GetComponent<PhotonView>();
}
public override void OnPlayerEnteredRoom(Player newPlayer)
{
PV.RPC("NotionRPC", RpcTarget.All, newPlayer.NickName + "님이 참가하셨습니다.");
}
public override void OnPlayerLeftRoom(Player otherPlayer)
{
PV.RPC("NotionRPC", RpcTarget.All, otherPlayer.NickName + "님이 퇴장하셨습니다.");
}
[PunRPC]
void NotionRPC(string msg)
{
Debug.Log(msg);
notionText.text = msg;
}
}
- 포톤 공식 Api 참고
https://doc.photonengine.com/ko-kr/pun/v1/gameplay/rpcsandraiseevent
반응형