Can't seem to save Image and Load it Back

So i’ve been struggling and this is my last resort. can someone plz help me find a way to save user imported image as bytes and then call it back as a byte and into a sprite. I’ve tried everything but the closest I’ve gotten is making question mark happened.

if you wanna see my code just ask.
Thanks

Use these to save a texture to bytes[ ], based on the desired format (I recommend PNG as it’s lossless):

Use this to save it to a file:

Use this to load an image from a file:

Use this to decode the bytes back into a texture:

Use this to create your Sprite at runtime:

The EncodeToPng link even has a sample of how to save an image and upload it to the web.

If you’re still not sure you can paste the code here with the Insert Code: [<>] button on the post editor options bar.

This is the loading after saving


This part bellow is Saving it

I’ve tried other way of but the results were worst.
hope this help you help me.

also i already read most of the API provided by unity.

ah, don’t use the Load/Save RawTextureData. That’s for very specific use cases and is specific to the GPU (it doesn’t save as normal image data, it’s litterally what the GPU format is and if you’re loading user-submitted content / normal image files, it won’t work at all). use the ImageConversion tools and normal image files instead.

Also, I’d assign the created sprite to the instantiated element, not the comps prefab/prototype.

I honestly don’t know why its not working. its saying that it cant create a sprite from a given texture. I tried changing the sprite size but the results didn’t get better.