Ready-made uGUI prefabs for the common Discord Social screens. Drop one under a Canvas and it works: the components are already wired to the labels, buttons and lists. They are visually functional but not styled or branded, so they are easy to restyle. Each one is a normal prefab you can unpack and change.
Import them from Window > Package Manager > Toolkit for Discord Social > Samples > Prefabs > Import. Samples are not part of the package itself: Unity keeps them in a separate list until you import them, and then copies them into Assets/Samples/.
Requirements #
- Unity 6, with uGUI and TextMeshPro, and an EventSystem in the scene.
- Foundation for Discord Social, the Discord Social SDK 1.10 or newer and the Game Framework (Heathen Toolbox installs the first and the last).
- Your Discord Application Id in Project Settings > Subsystems > Discord Social.
Nothing else goes in the scene. Discord Social is a subsystem that starts itself, signs the player in again with the saved sign-in and keeps their token, so the prefabs do not need an initialiser component.
The prefabs #
| Prefab | What it is | Main components |
|---|---|---|
Sign In | One button. It reads “Sign in” when signed out and “Sign out” when signed in, and is disabled while it works. | DiscordSignInButton |
User Profile | Avatar, name, status text and a status dot for one user. | DiscordUserData, SetDiscordUserAvatar, SetDiscordUserName, SetDiscordUserStatus |
Friends List | The friends list with search, an Invite button per friend and a Groups toggle. | DiscordUserList, DiscordInviteButton |
Lobby and Voice | Create or join a lobby, copy the code, see members, join or leave voice, and a Settings dropdown. | DiscordLobbySession, DiscordLobbyCode, DiscordJoinLobby, DiscordLobbyMemberList, DiscordVoiceBar, DiscordVoiceParticipantList, DiscordVoiceSettingsPanel, DiscordVoiceOutputToggle |
Guild List | The player’s Discord servers. Names only, which is all the SDK reports. | DiscordGuildList |
Friend Row, Group Header, Lobby Member Row, Voice Participant Row | The templates the lists above create one of for each item. Restyle the list by restyling these. | DiscordUserData, DiscordVoiceParticipantRow |
How to use one #
- Import the sample and open a scene with a Canvas and an EventSystem.
- Drag the prefab under the Canvas.
- Press Play. Press Sign in the first time and approve in the browser. From then on the player is signed in on launch.
- To change one, unpack it (right-click, Prefab > Unpack) or edit the prefab asset. If you replace a label or a button, point the
component’s field at the new one.
Showing a user: DiscordUserData #
DiscordUserData (menu Discord Social > User, from Foundation for Discord Social) holds one Discord user and tells the components under it when that user changes. The Toolkit’s name, avatar and status components find it on their own GameObject or a parent and update when it changes.
There are three ways to give it a user:
- Tick Local User to follow the signed in player. The
User Profileprefab shows how. - Call
Bind(UserData)orBind(ulong id)from code. - Let a list bind it. Every list in the Toolkit binds each row it creates.
profile.GetComponent<DiscordUserData>().Bind(new UserData(discordUserId));
Friends List groups #
Tick Groups to arrange friends in groups. The groups are a list on DiscordUserList; the Inspector’s + adds one. Each group has a name, the statuses it holds, a “takes everyone else” tick and a start-collapsed tick. The defaults are:
| Group | Statuses |
|---|---|
| Online | Online, Streaming |
| Away | Idle, Do Not Disturb |
| Offline | Everyone not claimed by another group |
A friend goes to the first group that lists their status, or else to the group that takes everyone else. A friend who matches no group is hidden. The header template (Group Header) has a toggle that collapses its group, and the header text is set by the Header Format field, where {0} is the group name and {1} the number of friends. Friends who are invisible are reported by Discord as offline.
Lobby and Voice #
The Lobby and Voice prefab contains the DiscordLobbySession, so one is in the scene once you place it. Friends List’s Invite button finds it and invites the friend to that lobby. The Settings toggle opens a panel with the voice output (device or 3D through Unity AudioSources), the microphone and speaker pickers, volumes, input mode and the noise and echo options. See Docs/Voice.md in the Demo Game (Template) sample for 3D voice.
Where to go next #
Demo Game (Template) is a complete project that uses these components, with the networking left open. Its Docs folder starts at Docs/INDEX.md.