Nakama Leaderboards Sample Project #
The official sample project for the Nakama Leaderboards system. Built with minimal boilerplate so you can easily copy the code into your project and adapt the scripts and UI to suit your game.
Download Sample ProjectFeatures #
- Weekly and global leaderboards
- Real-time score updates
- Different ways to submit scores (Best, Set, Increment, Decrement)
- Primary and sub-scores for tie-breaking
- Built-in account switcher for testing
- Copy-paste friendly code
Quick Start #
- For optimal display, set your game resolution to 1920x1080 if it isn’t already
- Open
Assets/Scenes/Main.unity
- Hit Play and start exploring!
The project connects to our demo server so you can see leaderboards in action immediately.
Project Structure #
Assets/
├── UnityNakamaLeaderboards/
├── HeroicUI/ # UI assets and styling
├── Scripts/ # Main leaderboard code
├── UI/ # UI Builder files
└── ... # Everything else
Code Overview #
Main Controller (NakamaLeaderboardsController.cs
)
#
Handles all core operations including calling the Nakama Leaderboards API.
Authentication
|
|
Leaderboard Operations
|
|
Record View (LeaderboardRecordView.cs
)
#
Simple class that displays individual leaderboard entries:
|
|
Account Switcher #
The project includes a handy account switcher for testing:
- Create multiple test accounts
- Switch between accounts to simulate different players
- Great for testing leaderboard interactions
Find it under Tools > Nakama and use the dropdown to switch accounts.
Setting Up Your Own Nakama Server #
While this project works with our demo server, you’ll want to set up your own Nakama instance in order to create custom leaderboards with their own configurations, behaviours, 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 it to your server:
- Select NakamaLeaderboardController from the scene hierarchy panel.
- Open the Inspector tab.
- Look for the field inputs under Nakama Settings and replace them with the following:
- Scheme:
http
- Host:
127.0.0.1
- Port:
7350
- Server Key:
defaultkey
- Scheme:
In NakamaLeaderboardsController.cs
, update the leaderboard IDs:
|
|
Additional Resources #
