[!IMPORTANT] Version 2 is now in testing/alpha phase! I'm looking for volunteer testers (Furnyr/Dissonity#11)
Previously named Unity-Embedded-App-SDK. This project has been developed for Unity 2022 or later but it should work with all the LTS versions.
Dissonity is designed for a structure similar to the nested-messages example from Discord. You may want to familiarize with that project structure first.
using UnityEngine;
using static Dissonity.Api;
public class MyScript : MonoBehaviour
{
async void Start()
{
string userId = await GetUserId();
Debug.Log($"The user's id is {userId}");
SubActivityInstanceParticipantsUpdate((data) => {
Debug.Log("Received a participants update!");
});
}
}
[!NOTE]
You can implement these packages yourself, or start with the Node.js example project inside the examples folder.
This project consists of two main packages:
To use Dissonity you need a Node.js project that uses the Dissonity NPM package and a Unity project that uses the Unity package.
In the Unity project you will have access to methods that allow you to interact with the Embedded App SDK. Behind the scenes, the SDK is still in the Node.js part. Both packages share data to provide functionality.
When running the activity, your game build will be inside a nested iframe inside the Node.js client that we will call "child" (more on this later).
Installation
First of all, you need to have installed:
npm install dissonity
setupSdk
with your config (sample)dissonity-child
(sample)That's everything you need in the Node.js client.
Notice you don't need to manually create a DiscordSDK instance.
Window
> Package Manager
> Add package from git URL
https://github.com/Furnyr/Dissonity.git?path=/unity
Dissonity
> Discord Bridge
If you don't know how to test your activity refer to the Discord documentation.
[!IMPORTANT]
If you don't add the Discord Bridge object to your scene you won't be able to receive data from the SDK!
There are code samples and an example Node.js project (using Colyseus for multiplayer support!) inside the examples folder.
If you find a bug, don't hesitate to open an issue. Now go and build something cool! :)