List of runtime created Texture2d not saving into file.

Discussion and help for Easy Save 3

List of runtime created Texture2d not saving into file.

Postby Darren_R » Thu Sep 05, 2019 4:05 pm

Hi there,

I'm trying to save a list of Texture2D's that are created at runtime.

I am doing something wrong. I'm getting grey textures out at the other end. I initially thought it was ES3 but it's not. Sorry!

This is some test code that does the same thing.

Edit: Ok I am running into GPU/CPU memory issues I guess. Is there any way to get around this to save generated Texture2D's into an es3 file at runtime.

Edit2: This helped me fix the issue. ... ctive.html

Code: Select all
public class SaveImages : MonoBehaviour
    public RenderTexture TestTexture;
    public Texture2D texture2D;
    private string es3FilePath = "C:/Users/darre/OneDrive/Desktop/MapTest/";
    private string es3Filename = "MapTest";
    private string biomImageName = "BiomImageName";
    private string fileSufix = ".jpg";

    // Start is called before the first frame update
    void Start()
        //Create BiomMattes Texture2Ds
            for (int i = 0; i < 2; i++)
                texture2D = new Texture2D(1024, 1024,TextureFormat.ARGB32,false);
                ES3.SaveImage(texture2D, es3FilePath + "/" + es3Filename +"/"+ es3Filename + "_" + biomImageName + "_" + i + fileSufix);
                SaveTexture(texture2D, es3FilePath + "/" + es3Filename +"/"+ "NotES3_"+es3Filename + "_" + biomImageName + "_" + i + fileSufix);

//Some other image saving code I hacked together, this works fine.
public void SaveTexture (Texture2D texture, string pathAndFileName)
        byte[] bytes = texture.EncodeToPNG();
        System.IO.File.WriteAllBytes(pathAndFileName, bytes);

Posts: 1
Joined: Thu Sep 05, 2019 3:45 pm

Re: List of runtime created Texture2d not saving into file.

Postby Joel » Sat Sep 07, 2019 9:06 am

Darren_R wrote:This helped me fix the issue. ... ctive.html

Hi Darren,

Glad you managed to find a solution to your issue. I will leave this here in case it's of use to anyone else in the future.

All the best,
Joel Tebbett @ Moodkie Interactive
Twitter - Unity - LinkedIn
User avatar
Moodkie Staff
Posts: 2476
Joined: Wed Nov 07, 2012 10:32 pm

Return to General Discussion

Who is online

Users browsing this forum: No registered users and 2 guests