API reference
API reference
Select your platform
No SDKs available
No versions available

CustomMatchmaking Class

Extends MonoBehaviour
Component responsible for creating, joining and leaving game rooms upon developer request.
When using this component you'll also need to add another component to the same gameobject that implements the ICustomMatchmakingBehaviour interface.

Protected Fields

MatchmakingBehaviour : ICustomMatchmakingBehaviour
Signature
ICustomMatchmakingBehaviour MatchmakingBehaviour

Fields

onRoomCreationFinished : UnityEvent< RoomOperationResult >
Event called when a CreateRoom() operation finished.
Signature
UnityEvent<RoomOperationResult> onRoomCreationFinished
onRoomJoinFinished : UnityEvent< RoomOperationResult >
Event called when a JoinRoom operation finished.
Signature
UnityEvent<RoomOperationResult> onRoomJoinFinished
onRoomLeaveFinished : UnityEvent
Event called when a LeaveRoom operation finished.
Signature
UnityEvent onRoomLeaveFinished

Properties

ConnectedRoomToken : string
[Get]
Indicates the token of the game room you're currently connected to.
If not connected this is null.
Signature
string ConnectedRoomToken
IsConnected : bool
[Get]
Indicates whether you're currently connected to a game room.
Signature
bool IsConnected
IsPasswordProtected : bool
[Get][Set]
Signature
bool IsPasswordProtected
IsPrivate : bool
[Get][Set]
Signature
bool IsPrivate
LobbyName : string
[Get][Set]
Signature
string LobbyName
MaxPlayersPerRoom : int
[Get][Set]
Signature
int MaxPlayersPerRoom

Protected Methods

GenerateRoomPassword ()
Generates a random room password to be used in the created room when it's requested in a CreateRoom() operation.
May be overriden to implement your own random password generation.
Signature
virtual string GenerateRoomPassword()
Returns
string  A random room password to be used in the created room.

Methods

CreateRoom ()
Creates a new room with the selected options in the component public fields.
Signature
async Task< RoomOperationResult > CreateRoom()
Returns
async Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly created room.
CreateRoom ( options )
Creates a new room with the selected options.
Signature
async Task< RoomOperationResult > CreateRoom(RoomCreationOptions options)
Parameters
options: RoomCreationOptions  The selected options for creating a new room.
Returns
async Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly created room.
JoinOpenRoom ( roomLobby )
Joins a room with the selected roomLobby .
Signature
async Task< RoomOperationResult > JoinOpenRoom(string roomLobby)
Parameters
roomLobby: string  Identifier of the room lobby you want to join. This is the same lobby name used in the CreateRoom() and CreateRoom(RoomCreationOptions) operations.
Returns
async Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly joined room.
JoinRoom ( roomToken , roomPassword )
Joins a room with the selected roomToken and roomPassword .
Signature
async Task< RoomOperationResult > JoinRoom(string roomToken, string roomPassword)
Parameters
roomToken: string  Unique identifier of the room you want to join. This is obtained from the RoomOperationResult obtained after doing a CreateRoom() operation.
roomPassword: string  Optional password for rooms that require one when joining. This is obtained from the RoomOperationResult obtained after doing a CreateRoom() operation.
Returns
async Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly joined room.
LeaveRoom ()
Leaves the room you're currently connected to.
Signature
void LeaveRoom()
Returns
void

Inner Interface

ICustomMatchmakingBehaviour Interface

The interface used for implementing the matchmaking behaviour over different networking frameworks.
Currently there are implementations for Photon Fusion and Unity Netcode for Gameobjects but more may be added using this interface.

Properties

ConnectedRoomToken : string
[Get]
Indicates the token of the game room you're currently connected to.
If not connected this is null.
Signature
string ConnectedRoomToken
IsConnected : bool
[Get]
Indicates whether you're currently connected to a game room.
Signature
bool IsConnected
SupportsRoomPassword : bool
[Get]
Indicates whether the implementation of this interface supports room passwords.
This is also used for controlling which fields are shown in the inspector UI of the CustomMatchmaking component.
Signature
bool SupportsRoomPassword

Methods

CreateRoom ( options )
Creates a new room with the selected options .
Signature
Task< RoomOperationResult > CreateRoom(RoomCreationOptions options)
Parameters
options: RoomCreationOptions  The selected options for creating a new room.
Returns
Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly created room.
JoinOpenRoom ( lobbyName )
Joins an open room with the selected lobbyName .
Signature
Task< RoomOperationResult > JoinOpenRoom(string lobbyName)
Parameters
lobbyName: string  Identifier of the lobby name containing the rooms you want to join. This is the same lobby name used during the CreateRoom() operation.
Returns
Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly joined room.
JoinRoom ( roomToken , roomPassword )
Joins a room with the selected roomToken and roomPassword .
Signature
Task< RoomOperationResult > JoinRoom(string roomToken, string roomPassword=null)
Parameters
roomToken: string  Unique identifier of the room you want to join. This is obtained from the RoomOperationResult obtained after doing a CreateRoom() operation.
roomPassword: string  Optional password for rooms that require one when joining. This is obtained from the RoomOperationResult obtained after doing a CreateRoom() operation.
Returns
Task< RoomOperationResult >  A task you should await for and receive a result with the information on the newly joined room.
LeaveRoom ()
Leaves the room you're currently connected to.
Signature
void LeaveRoom()
Returns
void

Inner Structs

RoomCreationOptions Struct

Set of options to be passed to an ICustomMatchmakingBehaviour.CreateRoom operation indicating the desired room configuration.

Fields

IsPrivate : bool
Indicates whether this game room is private.
This causes the room to be hidden from a list of available rooms to other players and to only be joined by players who know it's unique identifier and password when one is set.
Signature
bool IsPrivate
LobbyName : string
Name of the game lobby this room belongs to.
Lobbies are often used by networking frameworks to group game rooms by type or map.
Signature
string LobbyName
MaxPlayersPerRoom : int
The maximum number of players allowed per game room.
Signature
int MaxPlayersPerRoom
RoomPassword : string
Optional password to be required for other players to be able to join this game room.
If no password is required this field should not be set or set to null
Signature
string RoomPassword

RoomOperationResult Struct

Carries the information about the ICustomMatchmakingBehaviour.CreateRoom operation.
When successful it holds the unique identifier and password other players will use to ICustomMatchmakingBehaviour.JoinRoom this game room. When unsuccessful it holds the error message specifying what went wrong.

Fields

ErrorMessage : string
Indicates what went wrong in the ICustomMatchmakingBehaviour.CreateRoom operation.
On success this is null.
Signature
string ErrorMessage
RoomPassword : string
Optional password of the created room to be used on ICustomMatchmakingBehaviour.JoinRoom operations.
When not used this is null.
Signature
string RoomPassword
RoomToken : string
Unique identifier of the created room to be used on ICustomMatchmakingBehaviour.JoinRoom operations.
Signature
string RoomToken

Properties

IsSuccess : bool
[Get]
Indicates whether the ICustomMatchmakingBehaviour.CreateRoom operation succeeded.
Signature
bool IsSuccess