Saving user painted prefabs
-
- Posts: 6
- Joined: Mon Jan 14, 2019 10:49 am
Saving user painted prefabs
I have a prefab in the scene that the player can paint using Carlos Wilkes' Paint in 3d. I am wanting to save the painted prefab and have it load back in. This is vr, so the painting is done through a render texture. Paint in 3d allows me to save the render texture out as a png, but I'm not sure how to tie that all in with Easy Save. Do I include the texture in the Easy Save file and then when loading the prefab, apply the texture after the prefab has loaded? Hopefully I'm making sense. Not looking for code as much as help with the methodology.
Re: Saving user painted prefabs
Hi there,
If I was doing this I would do the following:
All the best,
Joel
If I was doing this I would do the following:
- When you want to save, save the PNG data to a file using ES3.SaveRaw.
- When you come to load, use ES3.LoadImage to load the image as a Texture.
- Assign this texture to your render texture
All the best,
Joel
-
- Posts: 6
- Joined: Mon Jan 14, 2019 10:49 am
Re: Saving user painted prefabs
Thanks Joel.
I'll give it a shot!
I'll give it a shot!
-
- Posts: 6
- Joined: Mon Jan 14, 2019 10:49 am
Re: Saving user painted prefabs
Finally got a chance to try this out. Saving the textures out as png is working as expected.
However, when trying to load the image back in I get this error.
NullReferenceException: Object reference not set to an instance of an object
ES3.LoadRawBytes (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:558)
Below is how I'm trying to load image in.
This is the line the error is pointing to in the ES3 script:
However, when trying to load the image back in I get this error.
NullReferenceException: Object reference not set to an instance of an object
ES3.LoadRawBytes (ES3Settings settings) (at Assets/Plugins/Easy Save 3/Scripts/ES3.cs:558)
Below is how I'm trying to load image in.
Code: Select all
public void LoadImageFromFile(string fileNameToLoad)
{
ES3Settings.defaultSettings.path = folder + imagesFolder + fileNameToLoad + imageExtension;
if (ES3.FileExists(ES3Settings.defaultSettings.path))
{
var glassTexture = ES3.LoadImage(fileNameToLoad + imageExtension);
glassCases[0].GetComponent<Renderer>().material.SetTexture("_BaseMap", glassTexture);
}
else
{
Debug.Log(fileNameToLoad);
}
}
Code: Select all
if (stream.GetType() == typeof(System.IO.Compression.GZipStream))
-
- Posts: 6
- Joined: Mon Jan 14, 2019 10:49 am
Re: Saving user painted prefabs
Nevermind, I am a dumb.
Re: Saving user painted prefabs
Glad to hear you've (hopefully) managed to find a solution
All the best,
Joel