Nakama Tournaments Sample Project
The official sample project for the Nakama Tournaments system. Built with minimal boilerplate so you can copy the code into your project and adapt the scripts and UI to suit your game.
Download Sample ProjectFeatures #
- List and join active tournaments.
- Countdown timers and participation limits.
- Score submission with different operators (best, set, increment, decrement).
- Primary score and sub-score support for tie-breaking.
- Built-in account switcher for quick multi-account testing.
Installation #
The installation steps and resulting folder structure vary depending on whether you downloaded the project from GitHub or the Unity Asset Store.
This project was built with Unity 6.0+ in mind. While most of the template isn’t version-specific, the UI may not behave as intended on older versions of Unity.
For optimal display, set your game resolution in the Unity Editor to 1920×1080.
- Clone or download the Sample Projects repository onto your machine.
- From Unity Hub, select Add → Add project from disk and choose the top-level UnityNakamaTournaments folder.
- You may see warnings about Editor version incompatibility. You can ignore these as long as you’re on Unity 6 or later. Continue to the main Editor UI.
- Open the main scene: Assets → UnityNakamaTournaments → Scenes → Main.
- Press Play.
The project connects to our demo server so you can see tournaments in action immediately.
Folder structure #
Assets/
├── UnityNakamaTournaments/
│ ├── HeroicUI/ # UI assets and styling
│ ├── Scripts/ # Main tournament code
│ ├── UI/ # UI Builder files
│ └── ... # Everything else
├── Packages/ # Contains the Nakama Unity package
The core scripts live under Scripts:
NakamaTournamentsController.cs
— handles auth, tournament listing, joining, record pagination, and score submissions.TournamentView.cs
— renders a tournament listing (title, size/max counts, time remaining).TournamentRecordView.cs
— renders a record (rank, username, score, sub-score).
Code overview #
Main controller (NakamaTournamentsController.cs
)
#
Connects and authenticates with a device ID, then lists tournaments and updates the UI. Also handles joining tournaments, submitting scores, deleting the player’s record, and record pagination.
Authentication
|
|
API reference: Authentication
Tournament operations
|
|
API reference: Tournaments
Record browsing
|
|
The controller pins the owner’s record separately, shows the per-user submission limit (current/max
), and disables the submit button when the limit is reached. It also toggles between “joined” and “not joined” controls depending on whether the tournament is joinable.
Tournament view (TournamentView.cs
)
#
Displays each tournament’s title, current size vs. max size, and a time-remaining readout based on NextReset
.
Record view (TournamentRecordView.cs
)
#
Displays the player’s rank, username, score, and sub-score.
Account Switcher #
The Account Switcher lets you explore the project as different users without managing multiple builds. Use it to submit scores as different players and view a tournament from another perspective.
How to use:
- Open the Account Switcher panel (Tools > Nakama > Account Switcher).
- Select different accounts from the dropdown to switch between up to four test users.
- Each account is automatically created the first time you select it.
Key points:
- Only works while your game is running in Play mode.
- Usernames will display in the panel after switching to an account for the first time.
Setting up your own Nakama server #
While this project works with our demo server, you’ll want to set up your own Nakama instance to create custom tournaments with their own configurations, behavior, and rules. Using Docker, you can get up and running in minutes.
Read the full setup guide: Nakama installation docs
Connect this Unity project to your server #
After installing Nakama and running it locally, edit these settings in the Unity Editor to connect to your server:
Select NakamaTournamentsController in the scene hierarchy.
Open the Inspector tab.
Under Nakama Settings, set:
- Scheme:
http
- Host:
127.0.0.1
- Port:
7350
- Server Key:
defaultkey
- Scheme:
No ID configuration is required in the script—the UI lists tournaments returned by the server.
Additional resources #
