I need to create a sprite from a png at runtime. Originally I fetch pngs remotely - they are base64 encoded. So my task is to decode the base64 into the original png, and then initialise a Sprite from that png.
Haven’t actually tested this fully yet but it compiles:
byte[] dataImage = System.Convert.FromBase64String(imagedata[keyData]);
Texture2D mytexture = new Texture2D(1, 1); // no idea what default size would be?? is it important??
if (!mytexture.LoadImage(dataImage)) {
Debug.Log("Failed loading image data!");
}
else {
Debug.Log("LoadImage - Still sane here - size: " + mytexture.width + "x" + mytexture.height);
}