Version: 1.7
LanguageEnglish
  • C#

Suggest a change

Success!

Thank you for helping us improve the quality of Unity Documentation. Although we cannot accept all submissions, we do read each suggested change from our users and will make updates where applicable.

Close

Submission failed

For some reason your suggested change could not be submitted. Please <a>try again</a> in a few minutes. And thank you for taking the time to help us improve the quality of Unity Documentation.

Close

Cancel

Parameters

gallerySaveCallback Callback which will be executed when save images finished.
textures Textures to be saved.

Description

Save a list of Texture2D to gallery.

using System.Collections;
using System.Collections.Generic;
using UnityEngine;
using UnityEngine.OpenHarmony;

public class SaveImagesScript : MonoBehaviour { void Start() { StartCoroutine(TakeScreenshot()); }

private IEnumerator TakeScreenshot() { yield return new WaitForEndOfFrame(); Texture2D screenshot = new Texture2D(Screen.width, Screen.height, TextureFormat.RGB24, false); screenshot.ReadPixels(new Rect(0, 0, Screen.width, Screen.height), 0, 0); screenshot.Apply(); Gallery.SaveImages((strs) => { foreach (string str in strs) { Debug.Log($"Save path : {str}.\n"); } }, new List<Texture2D>{screenshot,screenshot,screenshot}); } }