예제 #1
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);
    }
예제 #2
0
    IEnumerator GetTexture()
    {
        UnityWebRequest www = UnityWebRequestTexture.GetTexture(imgUrl);

        yield return(www.SendWebRequest());

        if (www.isNetworkError || www.isHttpError)
        {
            Debug.Log(www.error);
        }
        else
        {
            Texture2D myTexture = ((DownloadHandlerTexture)www.downloadHandler).texture;

            resize.SetTexture(myTexture);
        }
    }