From 25b6f1dcde66fb9fe58645dd7526030646868973 Mon Sep 17 00:00:00 2001 From: Josh Wood Date: Thu, 28 Sep 2017 11:15:15 -0400 Subject: [PATCH] Miscellaneous Unity Fixes (#3) * Use simplified attribute names and ensure function calls are made with CallingConvention.Cdecl * Remove unused imports --- .../button-clicker/Assets/DiscordController.cs | 4 +--- examples/button-clicker/Assets/DiscordRpc.cs | 18 +++++++++--------- 2 files changed, 10 insertions(+), 12 deletions(-) diff --git a/examples/button-clicker/Assets/DiscordController.cs b/examples/button-clicker/Assets/DiscordController.cs index 1bc11d4..bde8ac3 100644 --- a/examples/button-clicker/Assets/DiscordController.cs +++ b/examples/button-clicker/Assets/DiscordController.cs @@ -1,6 +1,4 @@ -using System.Collections; -using System.Collections.Generic; -using UnityEngine; +using UnityEngine; public class DiscordController : MonoBehaviour { public DiscordRpc.RichPresence presence; diff --git a/examples/button-clicker/Assets/DiscordRpc.cs b/examples/button-clicker/Assets/DiscordRpc.cs index 447337f..47d4da9 100644 --- a/examples/button-clicker/Assets/DiscordRpc.cs +++ b/examples/button-clicker/Assets/DiscordRpc.cs @@ -2,19 +2,19 @@ public class DiscordRpc { - [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void ReadyCallback(); - [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void DisconnectedCallback(int errorCode, string message); - [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void ErrorCallback(int errorCode, string message); - [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void JoinCallback(string secret); - [UnmanagedFunctionPointerAttribute(CallingConvention.Cdecl)] + [UnmanagedFunctionPointer(CallingConvention.Cdecl)] public delegate void SpectateCallback(string secret); public struct EventHandlers @@ -46,16 +46,16 @@ public class DiscordRpc public bool instance; } - [DllImport("discord-rpc", EntryPoint = "Discord_Initialize")] + [DllImport("discord-rpc", EntryPoint = "Discord_Initialize", CallingConvention = CallingConvention.Cdecl)] public static extern void Initialize(string applicationId, ref EventHandlers handlers, bool autoRegister, string optionalSteamId); - [DllImport("discord-rpc", EntryPoint = "Discord_Shutdown")] + [DllImport("discord-rpc", EntryPoint = "Discord_Shutdown", CallingConvention = CallingConvention.Cdecl)] public static extern void Shutdown(); - [DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks")] + [DllImport("discord-rpc", EntryPoint = "Discord_RunCallbacks", CallingConvention = CallingConvention.Cdecl)] public static extern void RunCallbacks(); - [DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence")] + [DllImport("discord-rpc", EntryPoint = "Discord_UpdatePresence", CallingConvention = CallingConvention.Cdecl)] public static extern void UpdatePresence(ref RichPresence presence); }