Unity Initialization
Pure Code
You do NOT require any GameObjects to make Discord Social run. You can simply call our DiscordSocialApp API, and we will handle initialisation of the required objects and optionally start the connection process as soon as ready.
Namespace
using Heathen.DiscordSocialIntegration.API
Initialize
DiscordSocialApp.Initialize(123456789987654, true);
Provide your "Client ID", also sometimes called an "Application ID"

The second parameter (auto connect) indicates whether or not the system should attempt to connect once initialised. You can set this to false and request a connection on demand later.
Connect
If you choose to differ connection (passed false into the Initialise function), you will need to call Connect when ready.
DiscordSocialApp.Connect();
Events
The Discord Social SDK initialisation and connection process passes through a number of steps in the background. Each step is represented by a Unity Event you can listen to if desired. All events are part of the DiscordSocialApp static class, the same class you used to call Initialise and Connect.
OnAuthorizeResult
public static UnityEvent<ClientResult, string, string> OnAuthorizeResult
Triggers when OAuth authorisation provides the required callbacks.
OnConnect
public static UnityEvent OnConnect
Triggers when the system completes the connection.
OnDisconnect
public static UnityEvent OnDisconnect
Triggers when the system disconnects from Discord.
OnReady
public static UnityEvent OnReady
Triggered when the system state updates to Ready and is thus ready to be used.
OnReceivedToken
public static UnityEvent OnReceivedToken
Triggard, when token retrieval completes
OnRetrieveTokenFailed
public static UnityEvent OnRetrieveTokenFailed
Triggered when the token request responds with a state of failed.
OnStatusChanged
public static UnityEvent<Client.Status, Client.Error, int> OnStatusChanged
Triggers with every system state change, connecting, connected, ready, disconnecting, disconnected, etc.
Object
When you configured your Discord Social Settings, it created DiscordSocialSettings
Objects that can be used to initialise directly. The initialisation function on these objects will read all required data from them.
Component
If you need a code-free solution, we provide you with a component script, Initialise Discord Social
which will initialise the Steamworks SDK for you based on your configured Steam Settings.

You DO NOT need to mark this component as Do Not Destroy on Load ... it does not need to persist between levels and only exists to call Initialise for you.
Last updated