Camera And Gallery

Saving Texture2D to the gallery.

You can specify gallery folder name setting in the plugin settings:

Open settings of the plugin: Window -> Stan's Assets -> Android Native -> Edit Settings:

By default a folder name is the same as a project name.

AndroidCamera.Instance.SaveImageToGallery(helloWorldTexture, "Screenshot" + AndroidCamera.GetRandomString());

Also you can save the app screenshot using the next code:

AndroidCamera.Instance.SaveScreenshotToGallery("Screenshot" + AndroidCamera.GetRandomString());

You can also find out image save result and image bath by subscribing on OnImageSaved event:

AndroidCamera.Instance.OnImageSaved += OnImageSaved;
AndroidCamera.Instance.SaveImageToGallery(helloWorldTexture, "Screenshot" + AndroidCamera.GetRandomString());

void OnImageSaved (GallerySaveResult result) {
    AndroidCamera.Instance.OnImageSaved -= OnImageSaved;

	if(result.IsSucceeded) {
		AN_PoupsProxy.showMessage("Saved", "Image saved to gallery \n" + "Path: " + result.imagePath);
		SA_StatusBar.text =  "Image saved to gallery";
	} else {
		AN_PoupsProxy.showMessage("Failed", "Image save to gallery failed");
		SA_StatusBar.text =  "Image save to gallery failed";

Note: Texture Should be marked as readable.


To subscribe on the image load event:

AndroidCamera.Instance.OnImagePicked += OnImagePicked;

Then retrieve the image from the gallery:


or retrieve the image from the camera:



Example of data retrieving when OnImagePicked action is fired:

private void OnImagePicked(AndroidImagePickResult result) {
    AndroidCamera.Instance.OnImagePicked -= OnImagePicked;

	if (result.IsSucceeded) {
		AN_PoupsProxy.showMessage ("Image Pick Rsult", "Succeeded, path: " + result.ImagePath);
		image.GetComponent<Renderer> ().material.mainTexture = result.Image;
	} else {
		AN_PoupsProxy.showMessage ("Image Pick Rsult", "Failed");

While taking the image from the camera you can also choose an image taking mode between Thumbnail and FullSizePhoto.

Open settings of the plugin: Window -> Stan's Assets -> Android Native -> Edit Settings:

While taking the image from the camera you can also choose image resolution between jpg and png.

Open settings of the plugin: Window -> Stan's Assets -> Android Native -> Edit Settings:

Note: Managing multiple full-sized images can be tricky with limited memory. If you find your application running out of memory after displaying just a few images, you can dramatically reduce the amount of dynamic heap used by expanding the JPEG into a memory by setting low max image size.

An example of API use can be found under the AnOtherFeaturesPreview.cs script.

Example Scene:

Plugins -> StansAssets -> Modules -> AndroidNative -> xExample -> Scenes -> Other -> OtherFeatures