Page 1 of 1
How to save an texture
Posted: Wed Feb 21, 2024 2:31 am
by Aldurroth
Hay there! I'm currently trying to save the texture on a Raw Image GUI object I have. Rite now when i try and save it it comes back missing. Is there a way to save this texture and reapply it to my Raw Image GUI object in my scene?
Re: How to save an texture
Posted: Wed Feb 21, 2024 8:20 am
by Tony Li
Hi,
Saved game data is serialized (i.e., converted into) a string so it can be written to storage such as a saved game file on disk. Unity doesn't serialize references to assets such as textures. One solution is to put your textures in a folder named Resources. Then write a
custom saver that saves the
name of the texture. When reloading your saved game, use Resources.Load<Texture2D>(name) to load the texture and assign it back to your Raw Image.