Beispiel #1
0
        private void PickImage(NativeAction actionPick)
        {
#if UNITY_ANDROID
            NativeGallery.RequestPermission((result, action) =>
            {
                if (result == (int)NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetImageFromGalleryForAndroid((path) =>
                    {
                        if (path.IsNotNullAndEmpty())
                        {
                            mPhotoPath = path;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + path, ImgPhoto);
                            BtnDel.gameObject.SetActive(true);
                        }
                        Debug.Log("Image path: " + path);
                    }, "选择图片", "image/*", false, action);
                }
            }, (int)actionPick);
#elif UNITY_IOS
            // NativeGallery.Permission rest;
            if (actionPick == NativeAction.Album)
            {
                NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(1);
                if (rest == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetImageFromGallery((backPath) =>
                    {
                        if (backPath.IsNotNullAndEmpty())
                        {
                            mPhotoPath = backPath;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + backPath, ImgPhoto, false);
                            BtnDel.gameObject.SetActive(true);
                        }
                    }, "选择图片", "image/*");
                }
            }
            else if (actionPick == NativeAction.Camera)
            {
                NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(4);
                if (rest == NativeGallery.Permission.Granted)
                {
                    NativeGallery.GetIPhoneCameraImageFromGallery((backPath) =>
                    {
                        if (backPath.IsNotNullAndEmpty())
                        {
                            mPhotoPath = backPath;
                            ImageDownloadUtils.Instance.SetAsyncImage("file://" + backPath, ImgPhoto, false);
                            BtnDel.gameObject.SetActive(true);
                        }
                    }, "选择图片", "image/*");
                }
            }
#else
#endif
        }
 /**
  * 打开原生相机拍照
  */
 private void IPhonePlayerSelectPictureOpenCamera()
 {
     NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(4);
     if (rest == NativeGallery.Permission.Granted)
     {
         NativeGallery.GetIPhoneCameraImageFromGallery((backPath) =>
         {
             if (backPath.IsNotNullAndEmpty())
             {
                 mPath          = backPath;
                 mThumbnailPath = backPath;
                 AudioContent.gameObject.SetActive(false);
                 if (mPath.IsNotNullAndEmpty())
                 {
                     ImageDownloadUtils.Instance.SetAsyncImage("file://" + mThumbnailPath, ImagePic);
                     BtnVideo.gameObject.SetActive(false);
                     BtnDel.gameObject.SetActive(true);
                 }
             }
         }, "选择图片", "image/*");
     }
 }
Beispiel #3
0
 /**
  * 打开原生相机拍照
  */
 private void IPhonePlayerSelectPictureOpenCamera()
 {
     NativeGallery.Permission rest = NativeGallery.RequestIPhonePermission(4);
     if (rest == NativeGallery.Permission.Granted)
     {
         NativeGallery.GetIPhoneCameraImageFromGallery((backPath) =>
         {
             if (backPath.IsNotNullAndEmpty())
             {
                 // 打开原生图片选择
                 UIMgr.OpenPanel <AttendanceAddPanel>(new AttendanceAddPanelData()
                 {
                     BoxId         = mData.BoxId,
                     BoxDay        = mData.BoxDay,
                     Path          = backPath,
                     ThumbnailPath = backPath,
                     Action        = AttendanceAdd.Pic
                 }, UITransitionType.CIRCLE);
                 Close();
             }
         }, "选择图片", "image/*");
     }
 }