- Home /
Question by
getconnect2ali · Sep 29, 2021 at 09:44 PM ·
c#texturestringjsonconversion
I want to convert image data(Texture2D) to Base64 string and store in JSON file in Unity3D(C#).
Hi,
I want to convert image(Texture2D) data to Base64 string and store in JSON format as of now am getting image texture, it's a kind of screenshot from live rendering camera. And I want the same image data into JSON format, Please suggest me with any example.
This is how am converting texture to Base64 then JSON.
Application.ExternalCall("screenshot", System.Convert.ToBase64String(texture.EncodeToPNG()));
string TextureArray = System.Convert.ToBase64String(texture.EncodeToPNG());
string serializedAbilites = JsonUtility.ToJson(TextureArray);
File.WriteAllText(Application.dataPath + "/File.json", TextureArray);
Thanks in advance! Any pointers/tips greatly appreciated.
Unity Version: 2020.3.11f1, language: C#
Comment
Your answer
Follow this Question
Related Questions
Get JSON array object string value 2 Answers
Converting string of a key into KeyCode 2 Answers
64k limit when convert byte[] to base64 string 1 Answer