How to save an texture

Announcements, support questions, and discussion for the Dialogue System.
Post Reply
Aldurroth
Posts: 43
Joined: Wed Jul 20, 2022 8:44 pm

How to save an texture

Post 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?
User avatar
Tony Li
Posts: 22110
Joined: Thu Jul 18, 2013 1:27 pm

Re: How to save an texture

Post 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.
Post Reply