Saving user painted prefabs

Discussion and help for Easy Save 3
Post Reply
Deedgeminds
Posts: 6
Joined: Mon Jan 14, 2019 10:49 am

Saving user painted prefabs

Post by Deedgeminds »

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.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving user painted prefabs

Post by Joel »

Hi there,

If I was doing this I would do the following:
  1. When you want to save, save the PNG data to a file using ES3.SaveRaw.
  2. When you come to load, use ES3.LoadImage to load the image as a Texture.
  3. Assign this texture to your render texture
Hope this helps.

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Deedgeminds
Posts: 6
Joined: Mon Jan 14, 2019 10:49 am

Re: Saving user painted prefabs

Post by Deedgeminds »

Thanks Joel.
I'll give it a shot!
Deedgeminds
Posts: 6
Joined: Mon Jan 14, 2019 10:49 am

Re: Saving user painted prefabs

Post by Deedgeminds »

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.

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);
        }

    }
This is the line the error is pointing to in the ES3 script:

Code: Select all

            if (stream.GetType() == typeof(System.IO.Compression.GZipStream))
Deedgeminds
Posts: 6
Joined: Mon Jan 14, 2019 10:49 am

Re: Saving user painted prefabs

Post by Deedgeminds »

Nevermind, I am a dumb.
User avatar
Joel
Moodkie Staff
Posts: 4846
Joined: Wed Nov 07, 2012 10:32 pm

Re: Saving user painted prefabs

Post by Joel »

Deedgeminds wrote: Thu Jul 23, 2020 4:22 pm Nevermind, I am a dumb.
Glad to hear you've (hopefully) managed to find a solution :)

All the best,
Joel
Joel @ Moodkie Interactive
Purchase Easy Save | Contact | Guides | Docs | Getting started
Post Reply