From 0f7e3ced25ee1138980f4ddfcb37e45fbc54bead Mon Sep 17 00:00:00 2001 From: Andrew Lee Date: Sat, 5 Dec 2020 13:18:39 -0500 Subject: Discord RPC; Removed jumping function for now --- Assets/Plugins/DiscordGameSDK/ImageManager.cs | 53 +++++++++++++++++++++++++++ 1 file changed, 53 insertions(+) create mode 100644 Assets/Plugins/DiscordGameSDK/ImageManager.cs (limited to 'Assets/Plugins/DiscordGameSDK/ImageManager.cs') diff --git a/Assets/Plugins/DiscordGameSDK/ImageManager.cs b/Assets/Plugins/DiscordGameSDK/ImageManager.cs new file mode 100644 index 0000000..292e230 --- /dev/null +++ b/Assets/Plugins/DiscordGameSDK/ImageManager.cs @@ -0,0 +1,53 @@ +using System; +using System.Runtime.InteropServices; +#if UNITY_EDITOR || UNITY_STANDALONE +using UnityEngine; +#endif + +namespace Discord +{ + public partial struct ImageHandle + { + static public ImageHandle User(Int64 id) + { + return User(id, 128); + } + + static public ImageHandle User(Int64 id, UInt32 size) + { + return new ImageHandle + { + Type = ImageType.User, + Id = id, + Size = size, + }; + } + } + + public partial class ImageManager + { + public void Fetch(ImageHandle handle, FetchHandler callback) + { + Fetch(handle, false, callback); + } + + public byte[] GetData(ImageHandle handle) + { + var dimensions = GetDimensions(handle); + var data = new byte[dimensions.Width * dimensions.Height * 4]; + GetData(handle, data); + return data; + } + +#if UNITY_EDITOR || UNITY_STANDALONE + public Texture2D GetTexture(ImageHandle handle) + { + var dimensions = GetDimensions(handle); + var texture = new Texture2D((int)dimensions.Width, (int)dimensions.Height, TextureFormat.RGBA32, false, true); + texture.LoadRawTextureData(GetData(handle)); + texture.Apply(); + return texture; + } +#endif + } +} -- cgit v1.2.3