Check out the Photo Cube Example on any Arm7 phone/tablet with Android 2.2 and up.
I am looking forward to people giving feedback, even on the Examples.
It should work with any Android Plugin compatible Unity version and of 2.2 and up.
Please check it out on your devices and post your comments, feature requests and questions.
Easily let Android users select images for your application to load.
Features:
use Gallery similar applications, let users Select an Image with one of their apps. Just set parameters and fire the event, fast and easy just a few lines of code needed.
Easy to Add. Does not extend UnityActivity, does not require complicated steps in working with other plugins
Examples Lots of examples in code, with comments and summary descriptions
Easy to set options, or just use one of the given examples
prevents externally loaded assets from crashing the game
Use the Camera Apps: Let the user select a Camera App to make a new image and get what they created
Receive through Share: Receive through Share, let users send images from external Apps to your application, if not running your application will start, if it is running you can check through a simple call if any images are ready to be received.
Default Actions: instead of showing all the apps, you can also directly open the default Camera or Image app the user has selected. If none has been selected yet, android will provide a pick a default app dialog, in which the user can select an app as default ājust onceā or āalwaysā.
debug callbacks, get specific levels of output where you want. Seperate from the original debug setting, you can use either or both or even none at all.
Add images to the gallery, create an album just for your App.
Removes rotation from images on devices that store orientation information.
Works on all Android versions supported by Unity3D
Android 4.4 KitKat fully supported
Multiple file selection (depends heavily on android version and available applications)
<NEW!> Video & preview, share & receive
<NEW!> Text share & receive
Keep those requests, questions or comments coming!
Please share your creations, post a link below or send me a link.
Applications that use Image Picker (please send me your links):
Turbo Dismount a kinetic tragedy about Mr. Dismount and the cars who love him.
Fingr a GPS/Map based social sharing and chat application
The debug output is slightly more informative now when processing images, showing
Bugfixes:
maxWidth and maxHeight will now correctly limit the returned texture
less memory used for downscaling images
Note:
out of all the options bestFit uses more memory when used, but returns an image that match at least one axis to the requested maximum image. If memory usage is still an issue, please lower the resolution when using bestFit, or disable bestFit and request a higher resolution image.
Version 6: (uploaded 14 oktober 2013)
Another huge update adding more features and fixes.
New:
Demo has been updated to include ImagePickerExample5 (scene 4- ) as well as the bugfixes and new functionalities listed below.
ImagePickerExample5.cs a cross platform aware, event based image loader (note ImagePicker for Android is still Android only).
Image rotation corrected on devices that store rotated images
Add to Gallery and a method to get the public Pictures folder for saving images (see Example5).
Optional callback when user cancels, if no callback is specified Unity will receive null in the image receiver callback.
Additional debug callbacks (verbose, warning and error) which work seperate from the debug setting.
Each callback will return that specific level of information (see Example5).
Note: Due to certain limitations, not all logcat information is sent (receiving files and adding to gallery is logcat only as there is no Unity link available at that stage).
Bugfixes:
images not loading on specific devices (Samsung Galaxy S3 and Galaxy Nexus)
Example 4 now correctly sets useDefault for the buttons added in the previous version
changes made in ImagePickerData.cs made MonoDevelop cry
ImagePickerData.cs now public to fix namespace issues
Changed:
Extra debug line to test if JNI was succesfull in ImagePicker
ImagePicker wrapper now also has awake
Example 1 with a much cleaner GUI
Polished out all warnings from the import of this plugin, except for one that reminds you this is an Android only plugin
Hi
Iām currently using prime31 plugins to take photos and browse the gallery with the native Android apps . Well it works but my app take a lot of RAM and so sometimes Android kills it while the user shoot or choose a photo.
So I wondered if your plugin handle this kind of problem.
Thank you
The Image Picker for Android plugin releases all internally used resources as soon as it can, but memory usage relies heavily on the resolution of the Image being loaded, at some point the device must process the whole thing, even if you only want/need a 256x256 image.
Also note that loading images on the Unity side can create these issues as well, especially when loading hundreds of textures.
The oldest device we have tested loading lots of textures on is a HTC Desire HD running Android 2.3.3, with no problems.
When trying to load images while in a scene that is already pushing memory usage to the max allowed by the Dalvik VM. Once you reach the magic number the app will be terminated, this number differs per device with some going as low as 16 MB.
Have you tried the demo apk to see if it works on your specific device?
The easiest way of stress testing the plugin is by sending Image Picker lots of pictures, then when the app is started goto the second scene and press āBegin receivingā. All the images will start loading into a 3D cylinder that you can rotate. Switch back to your gallery (donāt use the back key, itās set to close Image Picker) and send some more.
After loading a bunch of images check the memory usage, note that you can lower the resolutions of images processed simply by changing a parameter. Switching scenes in the Image Picker demo will cause Unity to release the textures.
This is as much as can be desired from any plugin, proper Memory usage remains the responsibility of the programmer. If the app does not work on low memory devices, look into filtering out those devices through the manifest or market settings to prevent users from having bad experiences with your app.
A bit of code to display the current memory usage might allow you to optimize memory usage for low-end devices, using MemoryInfo from the android API to check how much is available and loading low-mem resources instead.
I hope this answer helps you with the memory problems.
As Triss211 asked about out of memory issues, a quick test showed that Image Picker for Android currently does chrash when trying to access very large images and requesting resolutions of 2048x2048 or larger, it works fine for images of 1024x1024 and smaller.
Just did a quick test with ridiculously large 70MP images, which manages to chrash even when requesting small textures on the android side.
After figuring out the issue and 11811x8268 resolution jpeg which now loads correclty. Once I have cleaned up the code I will release version 7.
This might still not fix every memory problem you might be facing, but the plugin using the new loading method should use much less memory when loading images.
Hi Freezy, i bought the plug in yesterday (i was using another plug in for that but is not working and iām in trouble now).
I bought imagepicker android plug in because of many positive reviews but trying the test scene, i got the exact same problemā¦the app reboots if you click on both camera or image picker.
I checked the text file with instructions and everything was riteā¦do you have any idea how to solve the problem?
Iām actually stuck with my app (its a photo booth appā¦so, no camera, no app).
Thanks!
Ale.
Does the demo work on the device? If not than there is something wrong in the way your device and the plugin talk to each other (logcat should show what is wrong).
If the demo does work, using the debug settings and/or android logcat, should help identify the underlying issue(s).
With the little information provided, guessing the exact nature of the problem is just a stab in the dark.
What device and android version are you using?
Please check the logcat with debugging set to 3, start the app, clear logcat, try to launch the gallery and check which exception is thrown.
I recommend using the logcat view in Eclipse, it is very useful for android development (color coded, all kinds of filters) and free.
Here are some other tips that might help:
1: Do not run in emulator, Unity does not like it.
2: Double check SD Card writing permissions.
3: In the manifest are commented additional camera permissions, I believe they are not needed, as other apps are resolving the actual gallery / camera.
I would be happy to take a look at the logcat (donāt post the entire logcat here, please send it by e-mail or provide a link).
Hi Freezy, thanks for your help.
I managed to have a log at now, i had to check the whole log because using only the unity logs there was no error but checking all the tasks i manage to see some error.
The very moment i click on the camera to take a picture, slightly before crashing i got this:
W/dalvikvm(28382): No implementation found for native Lcom/unity3d/player/UnityPlayer;.UnitySendMessage:(Ljava/lang/String;Ljava/lang/String;Ljava/lang/String;)V
W/dalvikvm(28382): threadid=1: thread exiting with uncaught exception (group=0x416eb930)
Running on a Samsung Galaxy Tab 2 and Android 4.1
tested on an S4 same thingā¦
This happens with the demo scene, i will use the plug in in my project only when i managed to make it work on the demo scene.
From your second post I still canāt figure out if the demo apk works on your device, have you tested the demo apk?
This is step one, to see if I can build something that runs on the devices you are testing on.
Next up, are you using code stripping? I have had no problems with using maximum code stripping, but this error would indicate that Java canāt find the unityplayer and/or itās sendmessage could not be found. The other way this could happen is if the Unity dllās are not loaded yet (either not loaded or not included in the manifest), or the app is starting the camera from a native interface and expecting the Unity engine to start after the camera was used.
The easiest way to get the plugin to work:
create a new unity project
import the plugin asset package
set to android build, set SD card write permissions
add one or more example scenes to the player build list
This should result in a working build. The package already sets the folders in the correct places and the modified manifest (the bare minumum requires the intent to be added to the manifest).
If this does not work, please e-mail me (support@ElicitIce.com) this project and the built apk, hopefully I can figure out what is going wrong and get a fix for the problem as soon as possible.
If anyone else is reading this, please let us know, having multiple accounts of the same issue might speed up finding the cause.
I contacted iguana_02 about the issues he was having, turns out that the project he was building worked fine on other devices and after a device factory reset the plugin worked fine on the device having issues.
So far this seems to be an isolated incident, should anyone else experience similar issues please let me know.
Iāve bought this plugin and itās working great! Question though, can I use this plugin to load images from disk to my Unity3D Android project at runtime on an Android device?
I hope understand your question correctly.
You would like to use a Android device attached to the PC to send the selected image to the Editor while the editor is in run mode.
Short answer: No, there is nothing I can directly use in Unity to make this happen.
Long answer: No, but you can create code with UNITY_EDITOR pragma for testing the application in the editor.
Runtime in the editor does not actually run an emulated Android, it lacks the JNI required to make JAR based plugins work.
The Play mode in the editor doesnāt actually run on android, even when using the unity app for debugging.
The debugger can profile the application as it is running, but there is no link to the editor scene.
However there is code in place to detect if Unity is running in Anroid and Editor mode, so you could extend the code to open a file picker on windows, or load a predefined test image. This could be used to create a test case, where you randomly select one from X amount of textures to be loaded.
I hope this helps, if it doesnāt please rephrase the question.
Also, thank you for your purchase itās greatly appreciated.
Hi Freezy,
I bought the plugin today and everything is working perfectly! Now I want to do a 2D game which have a Playerbody (Sprite) with no head. I created a oval shape for the head and i want to import the head from the gallery or from the camera to the oval shape. But how can I edit the picture so you can just see the head in the oval shape?
Iām not sure you can edit a sprite, worst case scenario is use a Quad or custom mesh with a unlit texture shader, and keep it facing the camera using a script or rigidbody2D.
Create a customization step where the user can tweak the selection.
If you display a cutout indicator on screen, you can let the user drag the loaded image into the correct position.
As a start, create a rectangle indicator and let the user scale itās dimensions using integers.
Fancy stuff could be added to rotate and scale the texture to get the perfect position, but this would make the math harder.
Then copy the pixels or use a camera render target to get the pixels to the head texture, making sure to set the alpha using the shape you want or letting the UV settings on your oval mesh do this auto-magically.
I know some android applications support facial recognition (not always perfect), but I have not seen this data being stored in the image, also not all devices and applications support it. So you will need a way for users to select the face (and / or pixels) they want to use either way.
This sounds like a fun way to use user data, please send me a link or email when you got something working.
You understand my question wrong let me make it more clear.
What i basically need is to load a png from the Android device (SD card whatever). To my Android game. When iām using your picker I can make pictures, iām saving those pictures to the SD card as a png file. When the app is reopend again I need to load this user picture into Unity3D to the corresponding user. So something like LoadPNGtoTexture2D function
Take a look at the cube example, it loads the images from previous sessions.
You will need to either:
A. Assign a fixed path and name and check if a texture with that name is available at the desired path. Pass the desired path and name to ImagePickerData so that you donāt need to move it
or
B. Or keep track of the image passed to you by the plugin, by storing the location to the settings / save-game.
Either way should do the trick nicely.
For other users: If the application is just using the Image Picker plugin as a temporary cache I recommend assigning a single file as the cache, otherwise the default behavior will cause all images ever loaded to remain in the application data folder.
Alternatively to keep the cache tidy, you could just delete the file after loading or clear a specific temporary folder at start up.
The plugin gets you the file in a specific location, where it will remain untill you (or the user) decides to remove it.
I hope this information helps, if not please let me know.
Hi Freezy,
It was always working for me perfectly. But now if I click on Import a Picture nothing happens. I have no idea why its not working anymore. When I make a New Project with nothing in it only the Image Picker i got these errors:
This errors looks like you are trying to run the plugin in the editor, which is not possible (as there is no Java to connect to and there are no applications).
These steps should help:
Make sure the project is set to Android platform
The plugin only works on actual Android devices, as Unity3D editor is not running an actual Android emulation.
If it doesnāt run on a device, try the demo first to see if itās the plugin, device or you code.
3A. If the demo doesnāt work, there is something wrong with the device, try the demo code with debug enabled in ImagePickerData, check the logcat data for the cause (or e-mail it to our support e-mail).
3B. If the demo does work, then there is something wrong / missing in the project or code, compare against the demo scenes (or e-mail the project to our support).
If the demo works and you implementation in a new project works, then you should be able to determine what was missing in the original project and fix it.
Hopefully this helps, if it doesnāt please let me know.
Your application is not working unless in development.
Creating a new project displays the errors you stated previously
For the first problem:
The first step always remains the same, is the demo working correctly?
This step should be done everytime something stops working as it is the best baseline I can think of to check where the problems might originate.
The demo was built with development disabled, so if it works we know that it is possible.
Event though the device might have worked before, there could have been changes, such as apps crashing which can destabilize the functionality.
If the demo did work but isnāt working anymore, restarting the device once could help.
If the demo doesnāt work ( or works incorrectly ) I would really like to dig in the logcat of such devices and check what the problem might be.
The second problem:
When does the error appear? In the editor on runmode or are you receiving debug information from the actual device inside the editor?
Are there any warnings in the output when not building in development?
Are there any errors/warnings in logcat? I can highly recommend using the logcat view in eclipse you can filter by level and search for specific words.
These errors could also occur if the plugin folder was not added, or the manifest was not setup to include the required plugin code.
Check the manifest from the plugin and read the comments for what you might need to add to your applications manifest.
If none of these points help, please tell me the results of the debugging in as much detail as you can.
Hopefully I can fix the issues for you in one or two more posts