mirror of
https://github.com/yuzu-emu/discord-rpc.git
synced 2024-12-23 06:45:31 +00:00
Unity example working better.
This commit is contained in:
parent
f06b187d2d
commit
f6853fac1b
|
@ -3,12 +3,13 @@ using System.Collections.Generic;
|
||||||
using UnityEngine;
|
using UnityEngine;
|
||||||
|
|
||||||
public class DiscordController : MonoBehaviour {
|
public class DiscordController : MonoBehaviour {
|
||||||
public DiscordRpc.EventHandlers handlers;
|
|
||||||
public DiscordRpc.RichPresence presence;
|
public DiscordRpc.RichPresence presence;
|
||||||
public string applicationId;
|
public string applicationId;
|
||||||
public int callbackCalls;
|
public int callbackCalls;
|
||||||
public int clickCounter;
|
public int clickCounter;
|
||||||
|
|
||||||
|
DiscordRpc.EventHandlers handlers;
|
||||||
|
|
||||||
public void OnClick()
|
public void OnClick()
|
||||||
{
|
{
|
||||||
Debug.Log("Discord: on click!");
|
Debug.Log("Discord: on click!");
|
||||||
|
@ -50,23 +51,23 @@ public class DiscordController : MonoBehaviour {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Start () {
|
void Start () {
|
||||||
handlers = new DiscordRpc.EventHandlers();
|
|
||||||
handlers.readyCallback = ReadyCallback;
|
|
||||||
handlers.disconnectedCallback = DisconnectedCallback;
|
|
||||||
handlers.errorCallback = ErrorCallback;
|
|
||||||
handlers.joinCallback = JoinCallback;
|
|
||||||
handlers.spectateCallback = SpectateCallback;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void Update () {
|
void Update () {
|
||||||
|
DiscordRpc.RunCallbacks();
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnEnable()
|
void OnEnable()
|
||||||
{
|
{
|
||||||
var p = System.Diagnostics.Process.GetCurrentProcess();
|
Debug.Log("Discord: init");
|
||||||
Debug.Log(string.Format("Discord: init {0}", p.Id));
|
|
||||||
callbackCalls = 0;
|
callbackCalls = 0;
|
||||||
|
|
||||||
|
handlers = new DiscordRpc.EventHandlers();
|
||||||
|
handlers.readyCallback = ReadyCallback;
|
||||||
|
handlers.disconnectedCallback += DisconnectedCallback;
|
||||||
|
handlers.errorCallback += ErrorCallback;
|
||||||
|
handlers.joinCallback += JoinCallback;
|
||||||
|
handlers.spectateCallback += SpectateCallback;
|
||||||
DiscordRpc.Initialize(applicationId, ref handlers, true);
|
DiscordRpc.Initialize(applicationId, ref handlers, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -17,7 +17,6 @@ public class DiscordRpc
|
||||||
[UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
|
[UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
|
||||||
public delegate void SpectateCallback(string secret);
|
public delegate void SpectateCallback(string secret);
|
||||||
|
|
||||||
[System.Serializable]
|
|
||||||
public struct EventHandlers
|
public struct EventHandlers
|
||||||
{
|
{
|
||||||
public ReadyCallback readyCallback;
|
public ReadyCallback readyCallback;
|
||||||
|
|
Binary file not shown.
|
@ -588,9 +588,9 @@ MonoBehaviour:
|
||||||
partyId: abcdefg
|
partyId: abcdefg
|
||||||
partySize: 1
|
partySize: 1
|
||||||
partyMax: 10
|
partyMax: 10
|
||||||
matchSecret: asdfasdfsafd
|
matchSecret:
|
||||||
joinSecret: klkdkfbnbldknfvb
|
joinSecret:
|
||||||
spectateSecret: nwertinvnvldfkvnk
|
spectateSecret:
|
||||||
instance: 0
|
instance: 0
|
||||||
applicationId: 338030514596216832
|
applicationId: 338030514596216832
|
||||||
callbackCalls: 0
|
callbackCalls: 0
|
||||||
|
|
Loading…
Reference in a new issue