Beispiel #1
0
    /// <summary>
    /// Gets an Image from the Gallery using the NativeGallery Plugin
    /// </summary>
    public void PickImage()
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                var newTexture  = DuplicateTexture(texture);
                Sprite mySprite = Sprite.Create(newTexture, new Rect(0.0f, 0.0f, newTexture.width, newTexture.height), new Vector2(0f, 0f), 100.0f);

                SourceImage.sprite = mySprite;
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);
        ResizeSourceSprite();
    }
Beispiel #2
0
    public void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }


                Texture2D readableText = new Texture2D(texture.width, texture.height);
                readableText           = duplicateTexture(texture);
                // readableText.LoadImage(texture.GetRawTextureData());
                Debug.Log(readableText.isReadable);
                resizeImage.SetTexture(readableText);
                SaveImageFromGallery(readableText);
                InstantiateImage(readableText);
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);
    }
Beispiel #3
0
    private void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                _imgTexture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (_imgTexture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                if (!_material.shader.isSupported)  // happens when Standard shader is not included in the build
                {
                    _material.shader = Shader.Find("Legacy Shaders/Diffuse");
                }


                _material.mainTexture = _imgTexture;
            }
        }, "Selecione uma imagem", "image/*");

        Debug.Log("Permission result: " + permission);
    }
    public void OnClickUploadImageButton()
    {
        //NativeGallery.PermisionType permisionType = new NativeGallery.PermissionType();
        NativeGallery.Permission per = NativeGallery.RequestPermission(new NativeGallery.PermissionType());

        // probably should do some permissions checking here

        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            if (path != null)
            {
                // Create Texture from selected image

                Texture2D texture = NativeGallery.LoadImageAtPath(path, 2073600, false);

                if (texture == null)
                {
                    return;
                }

                //StartCoroutine(UploadImage(texture));
                UploadImage(texture);
            }
        }, "Select an image", "image/*");
    }
    void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                // turn texture to sprite
                Sprite sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(.5f, .5f), 100f);
                Debug.Log("sprite created");
                // attach it to the button sprite
                characterImage.sprite = sprite;
            }
        }, "Select an image", "image/");

        Debug.Log("Permission result: " + permission);
    }
Beispiel #6
0
    public void PickImage(int maxSize)    //이미지를 가져오는 함수
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }
                Sprite sprite       = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(0.5f, 0.5f), 100f);
                profileImage.sprite = sprite;
                StartCoroutine(SaveImage(texture));
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);
        if (permission == NativeGallery.Permission.Denied)
        {
            NativeGallery.OpenSettings();
        }
    }
    public void OpenExplorer(int maxSize)
    {
        this.detector.GetComponent <scrDetector>().mode = 1;

        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                //Texture2D texture = new Texture2D(aux.width, aux.height);
                //texture.SetPixels(aux.GetPixels());
                //texture.Apply();
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }
                // Assign texture to a temporary quad and destroy it after 5 seconds
                this.image.texture = texture;
                this.detector.GetComponent <scrDetector>().boxFactory.GetComponent <scrBoxFactory>().DestroyBoxes();
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);
    }
Beispiel #8
0
    /// <summary>
    /// Select the image and process the request
    /// </summary>
    /// <param name="campaignName">name of the campaign</param>
    private void PickImage(string campaignName)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D tex = NativeGallery.LoadImageAtPath(path, 4096);
                if (tex == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                tex.Apply();
                var v = new Texture2D(2, 2);
                v.LoadImage(tex.EncodeToPNG(), false);
                v.Apply();


                ///map.sprite = Sprite.Create(v, new Rect(0.0f, 0.0f, v.width, v.height), new Vector2(0.5f, 0.5f), 100.0f);

                SharedImageData sid = new SharedImageData();
                sid.bytes           = v.EncodeToPNG();
                sid.info            = null;
                string finalPath    = SerializationManager.CreatePath(campaignName + "/NewMap.map");
                SerializationManager.SaveObject(finalPath, sid);
            }
        }, "Select a PNG image", "image/png", 4096);

        Debug.Log("Permission result: " + permission);
    }
 public void TakePhoto(int maxSize = -1)   
 {
                                                  //调用插件自带接口,拉取相册,内部有区分平台
     NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>      {
               
         Debug.Log("Image path: " + path);       
         if (path != null)
         {
                    {
                                           // 此Action为选取图片后的回调,返回一个Texture2D 
                         
                 Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);         
                 if (texture == null)
                 {
                              {
                                   
                         Debug.Log("Couldn't load texture from " + path);           
                         return;         
                     }
                 }
                         
                 Debug.Log(texture.name);        
                 head.texture  = texture; //将选择的图片对我们的RawImage进行赋值
                 Sprite sprite = Sprite.Create(texture, new Rect(0, 0, texture.width, texture.height), new Vector2(0.5f, 0.5f));
                 img.sprite    = sprite;
                 // img.tex = head.texture;
             }
         }
             
     }, "选择图片", "image/png", maxSize);
 }
Beispiel #10
0
    private void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            //Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }
                Sprite sp     = Sprite.Create(texture, new Rect(Vector2.zero, new Vector2(texture.width, texture.height)), Vector2.zero);
                GameObject ui = UIController.Instance.Push("PhotoSetting");
                ui.GetComponentInChildren <PhotoSetting>().Init(sp);


                // Assign texture to a temporary quad and destroy it after 5 seconds

                // If a procedural texture is not destroyed manually,
                // it will only be freed after a scene change
                //Destroy(texture, 5f);
            }
        }, "Select a PNG image", "image/png", maxSize);

        Debug.Log("Permission result: " + permission);
    }
Beispiel #11
0
    //Carica Texture all'interno del Prefab PictureImage utilizzato come quadro
    private void LoadImageInsidePicture()
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) => {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, IMG_MAXSIZE);

                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }


                foreach (GameObject element in GameObject.FindGameObjectsWithTag("TakePictureBtn"))
                {
                    element.SetActive(false);
                }


                EnableButtonPhoto();

                pictureGO = Instantiate(Resources.Load <GameObject>("Prefabs/Picture/PictureImage"));
                pictureGO.GetComponent <PictureController>().SetMediaPath(path);
                Util.ResizeScalePictureToPoint(pictureGO, texture);
                pictureGO.GetComponent <Renderer>().material.mainTexture = (Texture)texture;
                confirmSavePhotoBtn.GetComponent <SavePhotoController>().setPicture(pictureGO);
                confirmCancelPhotoBtn.GetComponent <SavePhotoController>().setPicture(pictureGO);
            }
        }, "Select a  image", "image/*", IMG_MAXSIZE);
        Debug.Log("Permission result: " + permission);
    }
Beispiel #12
0
    private void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            m_LocalFileName = path.ToString();
            int te          = UnityEngine.Random.Range(11111, 9999999);
            imageId         = te.ToString();

            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);

                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                /*
                 * // Assign texture to a temporary quad and destroy it after 5 seconds
                 * GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
                 * quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
                 * quad.transform.forward = Camera.main.transform.forward;
                 * quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);
                 *
                 *
                 *
                 * //Rect rec = new Rect(0, 0, texture.width, texture.height);
                 * //ProfilePic.GetComponent<Image>().sprite = Sprite.Create(texture, rec, new Vector2(0.5f, 0.5f), 100);
                 *
                 *
                 * Material material = quad.GetComponent<Renderer>().material;
                 * if (!material.shader.isSupported) // happens when Standard shader is not included in the build
                 *  material.shader = Shader.Find("Legacy Shaders/Diffuse");
                 *
                 * material.mainTexture = texture;
                 */

                ScreenShotGO.SetActive(true);
                Rect rec           = new Rect(0, 0, texture.width, texture.height);
                float rangecreator = texture.height / (float)texture.width;
                ScreenShotGO.transform.Find("Image").transform.GetComponent <Image>().rectTransform.localScale = new Vector3(1f, rangecreator, 1f);
                ScreenShotGO.transform.Find("Image").transform.GetComponent <Image>().sprite = Sprite.Create(texture, rec, new Vector2(0.5f, 0.5f), 100);
                ResultText.text += texture.height.ToString();
                StartCoroutine(TakeScreenShot(ScreenShotGO, texture));

                //CanvasGO.SetActive(false);

                //StartCoroutine(TakeScreenShot(CanvasGO, quad, texture));

                //Destroy(quad, 10f);

                //UploadImage(texture);
            }
        }, "Select a PNG image", "image/png", maxSize);

        //Debug.Log("Permission result: " + permission);
    }
Beispiel #13
0
    //选择一个png图片
    private void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image Path:" + path);
            if (path != null)
            {
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture form: " + path);
                    return;
                }
                GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);

                quad.transform.position   = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
                quad.transform.forward    = Camera.main.transform.forward;
                quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);

                Material material = quad.GetComponent <Renderer>().material;
                if (!material.shader.isSupported)
                {
                    material.shader = Shader.Find("Legacy Shaders/Diffuse");
                }
                material.mainTexture = texture;
                Destroy(quad, 5f);
                Destroy(texture, 5f);
            }
        }, "Select a PNG image", "image/png", maxSize);
        Debug.Log("Permisson result :" + permission);
    }
Beispiel #14
0
    public void PickImage(Image _targetImg, int _imgNumber)
    {
        NativeGallery.GetImageFromGallery((path) =>
        {
            if (path != null)
            {
                Texture2D texture = NativeGallery.LoadImageAtPath(path, -1, false);
                if (texture == null)
                {
                    return;
                }

                var size          = (texture.width < texture.height) ? texture.width : texture.height;
                _targetImg.sprite = Sprite.Create(texture, new Rect(0, 0, size, size), Vector2.zero);

                if (_imgNumber == 1)
                {
                    image1data = texture;
                }
                if (_imgNumber == 2)
                {
                    image2data = texture;
                }
                if (_imgNumber == 3)
                {
                    image3data = texture;
                }
            }
        });
    }
Beispiel #15
0
    private void PickImage()
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) => {
            if (path != null)
            {
                Texture2D texture = NativeGallery.LoadImageAtPath(path);

                if (texture == null)
                {
                    Debug.LogError("Não encontrou a imagem em: " + path);
                    return;
                }

                float width  = texture.width;
                float height = texture.height;

                if (width != 2 * height)
                {
                    Debug.LogError("Imagem está com dimensões inadequadas");
                    return;
                }

                sprite = Sprite.Create(texture, new Rect(0, 0, width, height), new Vector2(0.5f, 0.5f));

                controller.SpawnItem("Exemplo", sprite);
            }
        }, "Selecionar imagem 360");
    }
Beispiel #16
0
    private void PickImage()
    {
        isProcessing = true;

        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = new Texture2D(2, 2);
                texture.LoadImage(File.ReadAllBytes(path));

                // Assign texture to a temporary cube and destroy it after 5 seconds
                GameObject cube         = GameObject.CreatePrimitive(PrimitiveType.Cube);
                cube.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 10f;
                cube.transform.forward  = -Camera.main.transform.forward;
                cube.GetComponent <Renderer>().material.mainTexture = texture;
                Destroy(cube, 5f);
                // If a procedural texture is not destroyed manually,
                // it will only be freed after a scene change
                Destroy(texture, 5f);
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);

        isProcessing = false;
    }
Beispiel #17
0
    private void SetUpImgForCategory(GameName _game, string _categoryKey)
    {
        gameName    = _game;
        categoryKey = _categoryKey;

        var categoryData = categoryStorage.Categories[_categoryKey];

        Sprite sprite = null;

        NativeGallery.GetImageFromGallery((path) =>
        {
            if (path != null)
            {
                Texture2D texture = NativeGallery.LoadImageAtPath(path, -1, false);

                var size = (texture.width < texture.height) ? texture.width : texture.height;
                sprite   = Sprite.Create(texture, new Rect(0, 0, size, size), Vector2.zero);

                if (categoryData.IsCustom)
                {
                    UpdateCategoryImage(_categoryKey, sprite);
                }
                else
                {
                    SetUpImgToBaseCategory(_game, _categoryKey, sprite);
                }
            }
        });
    }
    public void PickImage(int maxSize)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                var tempPic = NativeGallery.LoadImageAtPath(path, maxSize);
                if (tempPic == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                _memorizePhotos.newPath       = path;
                _memorizePhotos.beginArrayAdd = true;

                _memorizePhotos.thumbnailList.Add(tempPic);
                _memorizePhotos.thumbnailIteration++;
                SetCurrentImage(path, tempPic, true);
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);
    }
Beispiel #19
0
    private void PickImage(int maxSize)
    {
        var AM = AppManager.Instance;

        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                this._path = path;
                Debug.Log("_path111 " + _path);
                if (AM.openNoteMedia)
                {
                    AppManager.Instance._noteMediaPaths.Add(path);
                }
                else
                {
                    AppManager.Instance._mediaPaths.Add(path);
                }
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                AddFile();
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }
                //Destroy(texture, 5f);
            }
        }, "Выберите изображения для объявления", "image/png", maxSize);
        Debug.Log("Permission result: " + permission);
    }
    public void StartGame(int i)
    {
        if (i == 2)
        {
            panel.SetActive(true); return;
        }
        if (s.Split(',').Length > 1)
        {
            if (i == 1)
            {
                NativeGallery.GetImageFromGallery(Callback, "Pick an image", "image/*", -1);
                i = 0;
            }
            else
            {
                i  = 0;
                s += ", ";
                print(s);
                tileLayoutManager.list.Add(s.Split(','));

                /*foreach (string[] s in tileLayoutManager.list)
                 * {
                 *  foreach(string st in s)
                 *  {
                 *      print(st);
                 *  }
                 * }*/
                tileLayoutManager.SaveList();
                ui.Return();
            }
            return;
        }
        Debug.Log("Not enough words");
    }
    public void PickImage(int maxSize = 10000)
    {
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // Create Texture from selected image
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }

                Sprite sprite = Sprite.Create(texture, new Rect(0f, 0f, texture.width, texture.height), new Vector2(.5f, .5f), 100f);
                if (sprite == null)
                {
                    Debug.Log("Error creating sprite");
                }
                imagenJugador.sprite = sprite;

                pathImagenJugador = path;
            }
        }, "Seleccionar imagen", "image/*");

        Debug.Log("Permission result: " + permission);
    }
    //NativeGallery 에셋-> https://github.com/yasirkula/UnityNativeGallery 지침활용
    private void PickImage(int maxSize)
    {
        //안드로이드 갤러리접근
        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
        {
            Debug.Log("Image path: " + path);
            if (path != null)
            {
                // 선택된 이미지의 Texture 생성
                Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                if (texture == null)
                {
                    Debug.Log("Couldn't load texture from " + path);
                    return;
                }
                //texture를 byte로 변환
                texture = duplicateTexture(texture);
                bytes   = texture.EncodeToPNG();
                Debug.Log("GallyPickup   " + bytes[0]);


                Destroy(texture, 5f);

                socket.instance.ImageServer_G();
            }
        }, "Select a PNG image", "image/png");

        Debug.Log("Permission result: " + permission);
    }
Beispiel #23
0
 /// <summary>
 /// Open window for image pick. Work on IOS/Android
 /// </summary>
 public void UploadAvatarFromGallery()
 {
     if (NativeGallery.CheckPermission() != NativeGallery.Permission.Granted)
     {
         NativeGallery.RequestPermission();
     }
     NativeGallery.GetImageFromGallery(OnImagePicked);
 }
    void SelectPhoto()
    {
#if UNITY_EDITOR
        Debug.Log("SelectPhoto In Editor");
        return;
#endif
        NativeGallery.GetImageFromGallery(OnGetPhotoCb, "Select Photo");
    }
Beispiel #25
0
    /// <summary>
    /// opens file choosing dialog
    /// </summary>

    public static string PickImage(int maxSize)
    {
        string result = null;

        NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) => {
            result = path;
        }, "Select a PNG image", "image/*", maxSize);
        return(result);
    }
Beispiel #26
0
        private void PickImage(int maxSize)
        {
            NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
            {
                Debug.Log("Image path: " + path);
                if (path != null)
                {
                    // Create Texture from selected image
                    Texture2D texture = NativeGallery.LoadImageAtPath(path, maxSize);
                    if (texture == null)
                    {
                        Debug.Log("Couldn't load texture from " + path);
                        return;
                    }

                    // Assign the image texture to the ImageQuad prefab in the Resources folder
                    //var imagePrefab = Resources.Load<ImageQuad>("ImageQuad");
                    //imagePrefab.Initialize(texture);

                    var imagePrefab = Instantiate(imageQuadPrefab);
                    imagePrefab.GetComponent <ImageQuad>().Initialize(texture);

                    imagePrefab.transform.position   = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
                    imagePrefab.transform.forward    = Camera.main.transform.forward;
                    imagePrefab.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);

                    PrefabCreator.Instance.SetARPrefab(imagePrefab);

                    imagePrefab.SetActive(false);

                    /*
                     * // Assign texture to a temporary quad and destroy it after 5 seconds
                     * GameObject quad = GameObject.CreatePrimitive(PrimitiveType.Quad);
                     * quad.transform.position = Camera.main.transform.position + Camera.main.transform.forward * 2.5f;
                     * quad.transform.forward = Camera.main.transform.forward;
                     * quad.transform.localScale = new Vector3(1f, texture.height / (float)texture.width, 1f);
                     *
                     * Material material = quad.GetComponent<Renderer>().material;
                     * if (!material.shader.isSupported) // happens when Standard shader is not included in the build
                     *      material.shader = Shader.Find("Legacy Shaders/Diffuse");
                     *
                     * material.mainTexture = texture;
                     */

                    //PrefabCreator.Instance.SetARPrefab(Resources.Load<ImageQuad>("ImageQuad").gameObject);

                    // Don't destroy quad
                    //Destroy(quad, 5f);

                    // If a procedural texture is not destroyed manually,
                    // it will only be freed after a scene change
                    //Destroy(texture, 5f);
                }
            }, "Select a PNG image", "image/png");

            Debug.Log("Permission result: " + permission);
        }
Beispiel #27
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
        }
Beispiel #28
0
 public void PickImage_2()
 {
     NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
     {
         if (path != null)
         {
             rawImage_2.texture = NativeGallery.LoadImageAtPath(path);
         }
     }, "Select a PNG image", "image/png");
 }
Beispiel #29
0
    private IEnumerator TryLoadTextureToSliceRoutine()
    {
        PrepareUIForSetup();

        yield return(null);

        var permission = NativeGallery.GetImageFromGallery(OnImagePicked, "Please pick an image");

        Debug.Log(permission);
    }
 public void ChooseImage()
 {
     NativeGallery.Permission permission = NativeGallery.GetImageFromGallery((path) =>
     {
         if (path != null)
         {
             targetManager.CreateNewTarget(path);
         }
     }, "Select a PNG image");
 }