C#
void OnEnable()
{
Debug.Log("Discord: init");
callbackCalls = 0;
discord = new Discord.Discord(461618159171141643, (UInt64)Discord.CreateFlags.Default);
discord.SetLogHook(Discord.LogLevel.Debug, (level, message) =>C#
void OnEnable()
{
Debug.Log("Discord: init");
callbackCalls = 0;
discord = new Discord.Discord(461618159171141643, (UInt64)Discord.CreateFlags.Default);
discord.SetLogHook(Discord.LogLevel.Debug, (level, message) =>| var relations = discord.GetRelationshipManager(); | |
| relations.Filter((ref Discord.Relationship relationship) => | |
| { | |
| return relationship.Type == Discord.RelationshipType.Friend && relationship.Presence.Activity.ApplicationId == MY_CLIENT_ID; | |
| } | |
| relations.OnRefresh += () => | |
| { | |
| for (uint i = 0; i < relations.Count(); i++) |
| void Main() | |
| { | |
| // Instantiate Discord and make a StoreManager | |
| var discord = new Discord.Create(MY_APPLICATION_ID, (UInt64)Discord.CreateFlags.Default); | |
| var storeManager = discord.GetStoreManager(); | |
| storeManager.FetchSkus(); | |
| storeManager.OnEntitlementCreate += (ref Discord.Entitlement entitlement) => | |
| { | |
| Console.WriteLine(string.Format("User {0} just got entitlement to {1}", entitlement.User.Id, entitlement.SkuId)); |
| int main(int, char**) | |
| { | |
| discord::Core* core{}; | |
| auto result = discord::Core::Create(MY_APPLICATION_ID, DiscordCreateFlags_Default, &core); | |
| core->StoreManager().FetchSkus(); | |
| core->StoreManager().OnEntitlementCreate.Connect( | |
| [&](discord::Entitlement const& entitlement) -> { | |
| discord::Sku* sku{}; | |
| core->StoreManager().GetSku(entitlement.SkuId, &sku); |
| var lobbyManager = discord.GetLobbyManager(); | |
| lobbyManager.ConnectLobby(lobbyId, lobbySecret, (Discord.Result result, ref Discord.Lobby lobby) => | |
| { | |
| if (result == Discord.Result.Ok) | |
| { | |
| // User is in the lobby | |
| lobbyManager.ConnectVoice(lobby.Id, (res) => | |
| { | |
| if (res == Discord.Result.Ok) | |
| { |
| struct DiscordState { | |
| std::unique_ptr<discord::Core> core; | |
| }; | |
| namespace { | |
| volatile bool interrupted{ false }; | |
| } | |
| int main() | |
| { |
| // This code is client #1. All is unity examples | |
| public void OnClick() | |
| { | |
| var lobbyManager = discord.GetLobbyManager(); | |
| lobbyManager.SendNetworkMessage(lobby.Id, 363446008341987328, 0, System.Text.Encoding.UTF8.GetBytes("Sup")); | |
| } | |
| void OnEnable() | |
| { |
So, the thing that's gonna help us here is making use of multiple manifests. When you create a config.json file to upload your game, you've got something that looks like this.
{
"application": {
"id": your_app_id,
"manifests": [
{
// a bunch of stuff
}| using System; | |
| using UnityEngine; | |
| [Serializable] | |
| public class DiscordJoinEvent : UnityEngine.Events.UnityEvent<string> {} | |
| [Serializable] | |
| public class DiscordSpectateEvent : UnityEngine.Events.UnityEvent<string> {} | |
| [Serializable] |