U3d—通过调用安卓相册接口获取图片并上传服务器 三分有点码
。
调用安卓接口获取图片格式为Texture2D
/// <summary>
/// 记录选取的照片在后期可以统一上传
/// </summary>
private List<string> pictureData = new List<string>();
/// <summary>
/// 从手机相册选择图片
/// </summary>
/// <param name="maxSize"></param>
public void SelectHeadIconFromAlbum(int maxSize = -1)
{
//调用插件自带接口,拉取相册,内部有区分平台
NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
{
Debug.Log("Image path: " + path);
if (path != null)
{
// 此texture为选取图片后的回调,返回一个Texture2D
Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
Debug.Log("HR:" + texture.name);