Last active
January 4, 2019 07:50
-
-
Save voxelbustersold/a8c603c7a4c9172ddb9c16b17ca023b9 to your computer and use it in GitHub Desktop.
Save Texture2D to Persistent Path
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Required Namesapce for using Utitlity Functions | |
using VoxelBusters.InstagramKit.Common.Utility; | |
// You need pass a texture2D which is marked as Readable in its inspector and pass saveName with extension. Ex: photo.png or photo.jpg | |
void SaveImage(Texture2D image, string saveName) | |
{ | |
byte[] data = null; | |
if (saveName.EndsWith("png")) | |
{ | |
data = ImageConversion.EncodeToPNG(image); | |
} | |
else | |
{ | |
data = ImageConversion.EncodeToJPG(image); | |
} | |
FileOperations.WriteAllBytes(Application.persistentDataPath + "/" + saveName, data); | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment