using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI; public class showAndroid : MonoBehaviour { // Start is called before the first frame update void Start() { } public Text text; public RawImage img; public void showImage() { NativeGallery.GetImageFromGallery((string path) => { Debug.Log("Image path: " + path); if (path != null) { text.text = path; // 此Action为选取图片后的回调,返回一个Texture2D Texture2D texture = NativeGallery.LoadImageAtPath(path, -1); if (texture == null) { Debug.Log("Couldn't load texture from " + path); return; } Debug.Log(texture.name); img.texture = texture; } }); } public void showVideo() { NativeGallery.GetVideoFromGallery((string path) => { Debug.Log("Video path: " + path); text.text = path; }); } // Update is called once per frame void Update() { } }