Comments (7)
Hi, @mole84
I expect to get path like the demo code on the README.
https://github.com/thedoritos/unimgpicker/blob/master/README.md
Could you provide more information? Such as...
- The code you wrote to get the path.
- The error log you got.
Thank you.
from unimgpicker.
There is no error any more, but if I use your example (without changing something), and I ulpoad something from my C:/ it returns me the following path in Debug.Log:
C:/Users/mole/AppData/LocalLow/kakeragames/unimgpicker/unimgpicker
But i uploaded the file from "C:/" , so the path is wrong.
It´s always the same path, no matter where I upload the file from
How do i get the path with filename?
by the way, the image is shown correctly on the cube.
from unimgpicker.
Thanks for the info.
Now I see what was your question.
Currently, Unimgpicker doesn't have a feature to get the original image path.
This is a security problem on iOS/Android. The path is abstracted on these platform and you can't read the file directly from the path. As a workaround, Unimgpicker copies the image to the app data directory where your app can read/write.
I assume you want the original filename. If you really need it, I would try! But it seems that we have to switch the image picking framework (for iOS), and it'll take a little more than a few days.
Thank you.
from unimgpicker.
Hi thedoritos,
thank you for reply.
I like to upload the selected file and maybe it is possible to convert and save the meshrenderer into jpg or png? If this is possible theres no need for getting the original filename.
Do you have an idea?
from unimgpicker.
Hi, @mole84
There is a workaround.
- Pick an image.
- Copy the image file at the path to anywhere you want.
- Do anything you like with the new file.
Note that the image Unimgpicker returns is not the original one. It is a copy as I mentioned above. And it may be downscaled according to the size
argument you'll pass.
If you pass a large number, you may get a high quality copy but it probably causes an OutOfMemory error.
Thank you.
from unimgpicker.
Hi thedoritos,
how to copy the image?
- Copy the image file at the path to anywhere you want.
from unimgpicker.
I did it that way and it is working:
`using UnityEngine;
using System.Collections;
using System.IO;
using UnityEngine.UI;
namespace Kakera
{
public class PickerController : MonoBehaviour
{
[SerializeField]
private Unimgpicker imagePicker;
// [SerializeField]
// private MeshRenderer imageRenderer;
void Awake()
{
imagePicker.Completed += (string path) =>
{
StartCoroutine(LoadImage(path));
};
}
public void OnPressShowPicker()
{
imagePicker.Show("Select Image", "unimgpicker", 1024);
}
private IEnumerator LoadImage(string path)
{
var url = "file://" + path;
var www = new WWW(url);
yield return www;
var texture = www.texture;
if (texture == null)
{
Debug.LogError("Failed to load texture url:" + url);
}
//output.material.mainTexture = texture;
var pngData = texture.EncodeToPNG();
if (pngData != null ){
Debug.Log (Application.persistentDataPath);
File.WriteAllBytes(Application.persistentDataPath + "/" +"testpic" + ".png", pngData);
}
else
Debug.Log("Could not convert " + texture.name + " to png. Skipping saving texture");
}
}
}`
from unimgpicker.
Related Issues (20)
- Unity 2018.3.0b5 Android Gradle Build Failed HOT 5
- Doesn't work with WebGL HOT 2
- Build with the latest Unity HOT 2
- Unimgpicker doesn't work when i push the button HOT 2
- unable to upload videos. I have modified the code and made the system work with videos, but the uimgpicker does not show videos when im trying to upload. Where can i change this setting.
- Not Working In Mobile
- Gradle error when build for android
- How to check image orientation of image HOT 4
- Problem with Unimgpicker HOT 3
- Handling of IllegalArgumentException
- How do we crop the image ? HOT 3
- can we make two cube and then ........... HOT 5
- Doesn't work on IOS device HOT 2
- リサイズ機能を戻して欲しい+Windows対応しました HOT 4
- Cancel response
- Alternative to using delgate to get URL HOT 1
- Image Picker: NullReferenceException
- How to make the orientation of img picker scene become landscape left?
- How can I use this to apply on an image instead of a mesh renderer? HOT 1
- How to get size before compression of image in android environment
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from unimgpicker.