private IEnumerator EnterRoomCoroutine( string i_roomName, OnEnterRoomCallback i_callback ) { while( string.IsNullOrEmpty( i_roomName ) ) { RoomInfo[ ] roomList = null; while( roomList == null || roomList.Length == 0 ) { yield return null; roomList = PhotonNetwork.GetRoomList(); } var room = roomList.FirstOrDefault( value => value.open ); if( room == null ) { continue; } i_roomName = roomList[ 0 ].name; } bool ret = false; ret = PhotonNetwork.JoinRoom( i_roomName ); if( !ret ) { i_callback( false ); yield break; } if( !PhotonNetwork.inRoom ) { yield break; } if( i_callback != null ) { i_callback( true ); } }
public void JoinRoom( string i_name = null, OnEnterRoomCallback i_callback = null ) { if( !PhotonNetwork.insideLobby ) { return; } StartCoroutine( EnterRoomCoroutine( i_name, i_callback ) ); }