Skip to content

Commit b9426ad

Browse files
load PNG from stream
1 parent bb34e6e commit b9426ad

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

loadPNG.cs

+17
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
public static Texture2D LoadPng(Stream fileStream)
2+
{
3+
Texture2D texture = null;
4+
5+
if (fileStream != null)
6+
{
7+
using (var memoryStream = new MemoryStream())
8+
{
9+
fileStream.CopyTo(memoryStream);
10+
11+
texture = new Texture2D(2, 2);
12+
texture.LoadImage(memoryStream.ToArray()); //This will auto-resize the texture dimensions.
13+
}
14+
}
15+
16+
return texture;
17+
}

0 commit comments

Comments
 (0)