Skip to main content

Add quick play menu - Quick match with dedicated server - (Unity module)

Last updated on July 28, 2025

What's on the menu

In this section, you'll learn how to prepare the UI menus for matchmaking. These UIs are defined in the following classes:

  • MatchmakingMenu: A C# class used to display the game mode selection before matchmaking.

    • C# file: Assets/Resources/Modules/Play/MatchmakingEssentials/Scripts/UI/MatchmakingMenu.cs
    • Prefab file: Assets/Resources/Modules/Play/MatchmakingEssentials/Prefabs/MatchmakingMenu.prefab
  • MatchmakingServerTypeMenu: A C# class used to display the server type selection (dedicated server or peer-to-peer) before matchmaking.

    • C# file: Assets/Resources/Modules/Play/MatchmakingEssentials/Scripts/UI/MatchmakingServerTypeMenu.cs
    • Prefab file: Assets/Resources/Modules/Play/MatchmakingEssentials/Prefabs/MatchmakingServerTypeMenu.prefab
  • MatchmakingDSMenu_Starter: A C# class used to display matchmaking states, such as matchmaking started, match found, and matchmaking canceled.

    • C# file: Assets/Resources/Modules/Play/MatchmakingDS/Scripts/UI/MatchmakingDSMenu_Starter.cs
    • Prefab file: Assets/Resources/Modules/Play/MatchmakingDS/Prefabs/MatchmakingDSMenu_Starter.prefab

Take a look at more details on how these UIs are constructed.

Matchmaking menu

Below is a preview of the MatchmakingMenu prefab. This prefab contains buttons to select a game mode before starting matchmaking.

Matchmaking menu preview Unity Byte Wars quick match dedicated server

The components used in this menu are defined in the MatchmakingMenu class. When one of the game mode buttons is clicked, the selected game mode is stored in the SelectedGameMode property.

public static InGameMode SelectedGameMode { get; private set; }

[SerializeField] private Button eliminationButton;
[SerializeField] private Button teamDeathMatchButton;
[SerializeField] private Button backButton;

Matchmaking server type menu

Below is a preview of the MatchmakingServerTypeMenu prefab. This prefab contains buttons to select a server type before starting matchmaking.

Matchmaking server type menu preview Unity Byte Wars quick match dedicated server

The components used in this menu are defined in the MatchmakingServerTypeMenu class. When one of the server type buttons is clicked, it will open the next menu based on the selected type. For example, if the dedicated server button is clicked, it will instantiate the MatchmakingDSMenu_Starter prefab.

[SerializeField] private Button dedicatedServerButton;
[SerializeField] private Button peerToPeerButton;
[SerializeField] private Button backButton;

Matchmaking DS menu

The MatchmakingDSMenu_Starter prefab contains a state switcher to display a specific menu based on the matchmaking state. To switch the menu state, it uses the component defined below in the MatchmakingDSMenu_Starter class.

[SerializeField] private MatchmakingStateSwitcher stateSwitcher;

Below is the list of states included in this menu.

  • Start matchmaking state

    This state displays a message indicating that matchmaking has started and that the matchmaking request is being sent.

    Matchmaking DS menu start matchmaking state preview Unity Byte Wars quick match dedicated server

  • Cancel matchmaking state

    This state displays a message indicating that matchmaking has been canceled.

    Matchmaking DS menu cancel matchmaking state preview Unity Byte Wars quick match dedicated server

  • Finding match state

    This state displays a message indicating that matchmaking is in progress. It also shows a button allowing the player to cancel the matchmaking process.

    Matchmaking DS menu finding match state preview Unity Byte Wars quick match dedicated server

  • Match found state

    This state displays a message indicating that matchmaking has successfully found matched players and is ready to create a new session.

    Matchmaking DS menu match found state preview Unity Byte Wars quick match dedicated server

  • Join match confirmation state

    This state displays a dialog with buttons allowing the player to either join the match or reject the match invitation. It also includes an auto-join countdown if the player does not make a selection.

    Matchmaking DS menu join match confirmation state preview Unity Byte Wars quick match dedicated server

  • Requesting server state

    This state displays a message indicating that the session is currently requesting a server to host the match. It also shows a button to cancel the request.

    Matchmaking DS menu requesting server state preview Unity Byte Wars quick match dedicated server

  • Error state

    This state displays any error messages that occurred during the matchmaking process. It also shows a button to retry matchmaking.

    Matchmaking DS menu error state preview Unity Byte Wars quick match dedicated server

Ready the UI

In this section, you will prepare the menus mentioned earlier to start integrating the matchmaking feature.

  1. Open the MatchmakingDSMenu_Starter class and create the function below. Later, you will use this function to send the start matchmaking request. For now, add the code below to switch the menu to the start matchmaking state.

    private void StartMatchmaking()
    {
    stateSwitcher.SetState(MatchmakingMenuState.StartMatchmaking);
    }
  2. Next, create the following function to cancel matchmaking. You will use this function later to send the cancel matchmaking request. For now, it switches the menu to the cancel matchmaking state.

    private void CancelMatchmaking(string matchTicketId)
    {
    stateSwitcher.SetState(MatchmakingMenuState.CancelMatchmaking);
    }
  3. Replace the pre-defined Awake() function with the code below to bind the retry button to restart matchmaking when a request fails.

    private void Awake()
    {
    stateSwitcher.OnRetryButtonClicked = StartMatchmaking;
    }
  4. Then, replace the the pre-defined OnEnable() function with the code below to start matchmaking automatically when the menu is displayed.

    private void OnEnable()
    {
    StartMatchmaking();
    }
  5. In the Unity Editor, navigate to Assets/Resources/Modules/Play/MatchmakingDS and open the MatchmakingDSEssentialsAssetConfig.asset. Ensure the module is activated in starter mode by checking both the Is Active and Is Starter Active checkboxes.

  6. Finally, play the game in the Editor. You should be able to navigate to the main menu via Play Online > Quick Play, select any game mode, and click on the Dedicated Server button. Then, the menu will switch to the start matchmaking state. Later, you will replace this behavior with the actual matchmaking request.

Resources