Hi, Im new to unity coding, and I’ve been searching how to save a photo in playerPref but I’ve found that you cannot put photo inside the PlayerPref.
What I’ve trying to do is to get the photo from internet, and store it inside app and every time i can load it even in offline Mode ( Actully saving the photo for ProfiePicture inside the app)
Ive also found this article on Internet:
but that post only shows how to save and i don’t have any idea how to load it back inside my material texture
PlayerPrefs is not the ideal method for saving photos to disk. Part of the reason is that on some platforms there is a limit to the amount of data that the PlayerPrefs can save. It would be a lot wiser to write the texture straight to the Application.persistantDataPath directory. This is a pretty straight-forward process, first convert the image to a byte array (EncodeToPNG/EncodeToJPG). Next make a call to File.WriteAllBytes(Application.persistantDataPath + “/saved image.png”). And that’s it for the writing. For the reading you first call File.ReadAllBytes(). Then create a Texture2D and call LoadImage(theBytes). Done.
Don’t think I said that. If you’re playing a web browser game, and want it to work offline you’re going to have a lot of work to do, and probably require that the data you need is cached in the browser cache.