summaryrefslogtreecommitdiff
path: root/Assets/Plugins/DiscordGameSDK/ImageManager.cs
diff options
context:
space:
mode:
authorAndrew Lee <alee14498@protonmail.com>2020-12-05 13:18:39 -0500
committerAndrew Lee <alee14498@protonmail.com>2020-12-05 13:18:39 -0500
commit0f7e3ced25ee1138980f4ddfcb37e45fbc54bead (patch)
tree33f34ab33f1af5bb3413372030ef25642eedded1 /Assets/Plugins/DiscordGameSDK/ImageManager.cs
parentdf8769c71a03c4fc47945e39eed16d500f82ad71 (diff)
downloadProject-Sandbox-0f7e3ced25ee1138980f4ddfcb37e45fbc54bead.tar.gz
Project-Sandbox-0f7e3ced25ee1138980f4ddfcb37e45fbc54bead.tar.bz2
Project-Sandbox-0f7e3ced25ee1138980f4ddfcb37e45fbc54bead.zip
Discord RPC; Removed jumping function for now
Diffstat (limited to 'Assets/Plugins/DiscordGameSDK/ImageManager.cs')
-rw-r--r--Assets/Plugins/DiscordGameSDK/ImageManager.cs53
1 files changed, 53 insertions, 0 deletions
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
+ }
+}