Show / Hide Table of Contents

    Saving and Loading Images

    Using the SaveSystemAPI API for saving images, you can save a texture as an image file:

    • PNG: SaveSystemAPI.SaveImagePNGAsync
    • JPG: SaveSystemAPI.SaveImageJPGAsync
    • EXR: SaveSystemAPI.SaveImageEXRAsync

    And then you can load them back using the SaveSystemAPI.LoadImageAsync method.

    Saving a Texture as PNG

    async void Start() {
    
        // The name of the image file (you can provide an absolute path too)
        string identifier = "image.png";
    
        // The simple data we're going to save
        Texture2D myTexture = Resources.Load<Texture2D>("myTexture");
    
        // Save the data associated with the identifier
        await SaveSystemAPI.SaveImagePNGAsync(identifier, myTexture);
    
        // Load back the saved data associated with the identifier
        Texture2D loadedTexture = await SaveSystemAPI.LoadImageAsync(identifier);
    }
    
    • Improve this Doc
    • 0 Comments