prefab save/load & Textures

Discussion and help for Easy Save 3
Post Reply
pierrenay
Posts: 17
Joined: Sun Sep 01, 2019 8:25 am

prefab save/load & Textures

Post by pierrenay »

I note that i get errors when trying to load an es3 saved prefab containing textures ( its a ui prefab) n order to load properly :
i cant have the texture in an atlas
i need to use crunch compression
and enable R/W.

Is this correct ?
User avatar
Joel
Moodkie Staff
Posts: 4849
Joined: Wed Nov 07, 2012 10:32 pm

Re: prefab save/load & Textures

Post by Joel »

Hi there,

If your Texture are generated or modified at runtime, then what you've described is correct. You would also need to ensure that they are saved by value rather than by reference, because otherwise a reference to that Texture won't exist between sessions.

By default Textures (and any field which derives from UnityEngine.Object) are saved by reference unless you're saving them directly. I.e. this will save by reference:

Code: Select all

ES3.Save("key", prefab.GetComponent<MeshRenderer>().sharedMaterial);
But this will save by value:

Code: Select all

ES3.Save("key", prefab.GetComponent<MeshRenderer>().sharedMaterial.mainTexture);
All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply