Nakama Groups Sample Project

The official sample project for the Nakama Groups 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 Project

Features #

  • Browse all public groups or filter to the ones you belong to.
  • Create new groups with custom avatars, privacy settings, and max member counts.
  • Submit join requests to invite-only groups or instantly join open groups.
  • Moderate memberships with accept, promote, demote, kick, and ban actions.
  • Built-in account switcher for quick multi-account testing.

Installation #

The installation steps and resulting folder structure will vary depending on if you downloaded the project from Github or the Unity Asset Store.

Notice

This project was built with Unity 6.0+ in mind. Whilst the majority of the template is not 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 1920x1080

  1. Clone or download the Sample Projects repository onto your machine.
  2. From the Unity Hub, click Add -> Add project from disk and choose the top-level UnityNakamaGroups folder.
  3. You may see several warnings about Editor version incompatibility. Feel free to ignore these messages as long as you’re on Unity 6 or greater. Continue on until you arrive at the main Editor UI.
  4. Open the main scene by navigating to Assets -> UnityNakamaGroups -> Scenes -> Main.
  5. Hit Play.

The project connects to our demo server so you can explore group creation, discovery, and moderation immediately.

Folder structure #

Assets/
├── UnityNakamaGroups/
    ├── HeroicUI/           # UI assets and styling
    ├── Scripts/            # Main groups management code
    ├── UI/                 # UI Builder files
    └── ...                 # Everything else
├── Packages/               # Contains the Nakama Unity package

Code overview #

Main Controller (NakamaGroupsController.cs) #

Coordinates all interactions with the Nakama Groups API.

Authentication

1
2
// Connect to Nakama server and authenticate with device ID
await AuthenticateWithDevice();

Group discovery

1
2
3
4
// List public groups with optional name filtering
var groupsResult = await Client.ListGroupsAsync(session, name: null, limit: 100);
// List groups the current user belongs to
var userGroupsResult = await Client.ListUserGroupsAsync(session, userId: null, limit: 100, cursor: string.Empty);

Group lifecycle

1
2
3
4
5
6
7
// Create a group with custom avatar and settings
await Client.CreateGroupAsync(session, "My Guild", "A competitive PvP guild",
    avatarJson, langTag: null, open: true, maxCount: 50);
// Manage group membership
await Client.DeleteGroupAsync(session, groupId);
await Client.JoinGroupAsync(session, groupId);
await Client.LeaveGroupAsync(session, groupId);

Membership moderation

1
2
3
4
5
6
// Manage join requests and member privileges
await Client.AddGroupUsersAsync(session, groupId, userIds: new[] { userId });      // Accept join request
await Client.PromoteGroupUsersAsync(session, groupId, userIds: new[] { userId });  // Promote to admin
await Client.DemoteGroupUsersAsync(session, groupId, userIds: new[] { userId });   // Demote to member
await Client.KickGroupUsersAsync(session, groupId, userIds: new[] { userId });     // Remove or decline request
await Client.BanGroupUsersAsync(session, groupId, userIds: new[] { userId });      // Ban permanently

Group listing (GroupView.cs) #

Renders individual group entries with custom avatars, names, and member counts.

Member management (GroupUserView.cs) #

Displays group members and join requests with role-based action buttons that adapt to the user’s permissions.

Account Switcher #

The project includes an account switcher for testing:

  • Create multiple test accounts
  • Switch between accounts to simulate different players
  • Great for testing group interactions from different roles

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 group 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:

  1. Select NakamaGroupsController from the scene hierarchy panel.
  2. Open the Inspector tab.
  3. Look for the field inputs under Nakama Settings and replace them with the following:
    1. Scheme: http
    2. Host: 127.0.0.1
    3. Port: 7350
    4. Server Key: defaultkey

Additional resources #