Skip to content

a Discord Rich Presence Plugin for your game (Unity3D Game Engine)

License

Notifications You must be signed in to change notification settings

imclaytoo/unity3d-discord-rp

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

9 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Unity3D - Discord Rich Presence

a Discord Rich Presence Plugin for your game (Unity3D Game Engine)

About

I'm made this Plugin using DiscordRichPresenceSDK package.

This Plugin Configuration is on Inspector, so you can attach it to any different GameObject on any spesific Scene

Getting Started

First, copy Assets folder, and Place to your Unity Project

Go to Discord Developer Application and make a New Application

alt img

Then go to OAuth2 > General

After that go to Redirect section and click Add Redirect

Put the redirect link that we want to use, which is http://127.0.0.1 then click Save Changes on the bottom

Go to your Unity Project, then open the script located at Assets/Plugins/DiscordGameSDK/DiscordController.cs

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using Discord;

public class DiscordController : MonoBehaviour
{
    public Discord.Discord discord;

    public string sDetails, sState, sLargeImage, sLargeText, sSmallImage, sSmallText;

    void Start()
    {
        discord = new Discord.Discord(/*PUT_YOUR_CLIENT ID_HERE*/, (System.UInt64)Discord.CreateFlags.Default);
        var activityManager = discord.GetActivityManager();
        var activity = new Discord.Activity
        {
            Details = sDetails,
            State = sState,
            Assets = 
            {
                LargeImage = sLargeImage,
                LargeText = sLargeText,
                SmallImage = sSmallImage,
                SmallText = sSmallText
            },
        };
        activityManager.UpdateActivity(activity, (res) => {
            if (res == Discord.Result.Ok)
                Debug.Log("Discord status set!");
            else
                Debug.LogError("Discord status failed!");
        });
    }

    void Update()
    {
        discord.RunCallbacks();
    }
}

Change the /* PUT_YOUR_CLIENT_ID_HERE */ with your CLIENT ID, CLIENT ID is located on OAuth2 > General

After that, you can attach DiscordController.cs script to any GameObject on your Scene.

This is How to Configure your Discord Rich Presence Status

  • S Details is for Details
  • S State is for State
  • S Large Image is for Large Image Name that you upload on Discord Developer Application Rich Presence > Art Assets > Rich Presence Assets
  • S Large Text is for text details on Large Image
  • S Small Image is for Small Image Name that you upload on Discord Developer Application Rich Presence > Art Assets > Rich Presence Assets
  • S Small Text is for text details on Small Image

*You can see how to putting an image down below on Optional Section

Here is the result

Discord RP Preview

This is optional

After that go to Rich Presence > Art Assets

Then click on Rich Presence Invite Image for changing Invite Image or Rich Presence Assets for changing RPS Image

Examples

*remember, file name is used on Unity Inspector

About

a Discord Rich Presence Plugin for your game (Unity3D Game Engine)

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages