Unity example working better.

This commit is contained in:
Chris Marsh 2017-08-02 17:52:20 -07:00
parent f06b187d2d
commit f6853fac1b
4 changed files with 15 additions and 15 deletions

View file

@ -3,12 +3,13 @@ using System.Collections.Generic;
using UnityEngine;
public class DiscordController : MonoBehaviour {
public DiscordRpc.EventHandlers handlers;
public DiscordRpc.RichPresence presence;
public string applicationId;
public int callbackCalls;
public int clickCounter;
DiscordRpc.EventHandlers handlers;
public void OnClick()
{
Debug.Log("Discord: on click!");
@ -50,23 +51,23 @@ public class DiscordController : MonoBehaviour {
}
void Start () {
handlers = new DiscordRpc.EventHandlers();
handlers.readyCallback = ReadyCallback;
handlers.disconnectedCallback = DisconnectedCallback;
handlers.errorCallback = ErrorCallback;
handlers.joinCallback = JoinCallback;
handlers.spectateCallback = SpectateCallback;
}
void Update () {
DiscordRpc.RunCallbacks();
}
void OnEnable()
{
var p = System.Diagnostics.Process.GetCurrentProcess();
Debug.Log(string.Format("Discord: init {0}", p.Id));
Debug.Log("Discord: init");
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);
}

View file

@ -17,7 +17,6 @@ public class DiscordRpc
[UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)]
public delegate void SpectateCallback(string secret);
[System.Serializable]
public struct EventHandlers
{
public ReadyCallback readyCallback;

View file

@ -588,9 +588,9 @@ MonoBehaviour:
partyId: abcdefg
partySize: 1
partyMax: 10
matchSecret: asdfasdfsafd
joinSecret: klkdkfbnbldknfvb
spectateSecret: nwertinvnvldfkvnk
matchSecret:
joinSecret:
spectateSecret:
instance: 0
applicationId: 338030514596216832
callbackCalls: 0