-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathTestByteArray.cs
More file actions
36 lines (32 loc) · 852 Bytes
/
TestByteArray.cs
File metadata and controls
36 lines (32 loc) · 852 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
using System.Threading.Tasks;
using UnityEngine;
namespace Nahoum.UnityJSInterop.Tests
{
public static class TestByteArray
{
[ExposeWeb]
public static Texture2D LoadTexture(byte[] imageBytes)
{
// Load the PNG
var tex = new Texture2D(2, 2);
tex.LoadImage(imageBytes);
return tex;
}
[ExposeWeb]
public static string GetTextureResolution(Texture2D tex)
{
return tex.width + "x" + tex.height;
}
[ExposeWeb]
public static void DestroyTexture(Texture2D tex)
{
// Release the texture
UnityEngine.Object.Destroy(tex);
}
[ExposeWeb]
public static int GetByteArrayLength(byte[] byteArray)
{
return byteArray.Length;
}
}
}