반응형
- 코드 작성
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Photon.Pun;
using Photon.Realtime;
using UnityEngine.UI;
using Hashtable = ExitGames.Client.Photon.Hashtable;
public class NetworkManager : MonoBehaviourPunCallbacks
{
public override void OnJoinedRoom()
{
statusText.text = "방에 참가하였습니다.";
if (PhotonNetwork.IsMasterClient)
{
PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { "RoomState", "Waiting" } });
PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { "Master", PlayerPrefs.GetString("NickName") } });
PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { "Number", 123 } });
}
}
void LoadRoomState() //방 상태 불러오기
{
if (PhotonNetwork.InRoom)
{
Hashtable ht = PhotonNetwork.CurrentRoom.CustomProperties;
switch (ht["RoomState"])
{
case "Waiting":
Debug.Log("방이 대기중입니다.");
break;
case "Play":
Debug.Log("방이 게임중입니다. 다음 게임부터 참여 가능합니다.");
break;
default:
break;
}
}
}
void UpdateRoomState() //방 상태 변경하기
{
if(PhotonNetwork.InRoom)
{
if(PhotonNetwork.IsMasterClient)
{
PhotonNetwork.CurrentRoom.SetCustomProperties(new Hashtable() { { "RoomState", "Playing" } });
}
}
}
}
반응형
'개발 > Photon' 카테고리의 다른 글
유니티 C# 포톤 코루틴 간단 사용 Photon Coroution (0) | 2022.12.22 |
---|---|
유니티 C# 포톤 씬 로드하기 Photon Scene Load (0) | 2022.12.22 |
유니티 C# 포톤 타이머 간단 구현 Photon Timer (0) | 2022.12.22 |
유니티 C# 포톤 소유권 제어하기 Photon Ownership (0) | 2022.12.22 |
유니티 C# 포톤 변수 동기화 Photon RPC (0) | 2022.12.22 |
유니티 C# 포톤 방 참가 퇴장 알림 간단 구현 Photon RPC (0) | 2022.12.22 |
유니티 C# 포톤 방 설정하기 Photon RoomOptions (0) | 2022.12.22 |
유니티 C# 포톤 서버 접속하기 간단 구현 Photon Server (0) | 2022.12.22 |
댓글