/// <summary> /// 部屋に参加する /// </summary> private static async Task <IResult <string, Unit> > JoinRoom(string roomName, bool createIfNoExists) { var joined = await PhotoTask.JoinRoom(roomName); if (joined.IsSuccess) { return(ToSuccess()); } if (!createIfNoExists) { return(ToFailure("No room.")); } // 部屋を作って参加する var created = await PhotoTask.CreateRoom(roomName, null, null, null); if (!created.IsSuccess) { //失敗 return(ToFailure(created.TryGetFailureValue.ToString())); } return(ToSuccess()); }
public async UniTask ConnectRoom(string roomName = "") { if (string.IsNullOrWhiteSpace(roomName)) { await FailureHandlingPhotonTask(PhotoTask.JoinRandomRoom(), _ => RoomManager.Instance.Model.JoinRoom(PhotonNetwork.room.Name)); } else { await FailureHandlingPhotonTask(PhotoTask.JoinRoom(roomName), _ => { var roomProperty = PhotonNetwork.room.CustomProperties; RoomManager.Instance.Model.JoinRoom(roomName); if(roomProperty.TryGetValue(RoomDefine.ANCHOR_KEY, out var anchorId)) { RoomManager.Instance.Model.SetAnchorId(anchorId.ToString()); } }); } }