If your main project uses ProGuard minification in Player Settings, you should add the following line to the ProGuard filters: -keep class com.yasirkula.unity.* { *; }. Let me know if your project uses a minification other than None and ProGuard.
Otherwise, assuming that both projects have Write Permission set to “External (SDCard)” and have the same AndroidManifest.xml files at exactly the same places, this issue shouldn’t occur.
I created empty project and included both plugins (Native Camera and UnimgPicker). Worked like a charm. No idea why it doesn’t work in my main project. Is it possible that I have a conflict with Firebase or Playfab? Since the Firebase files are in the Android catalogue before I put the Android Manifest there, could they create a conflict?
When the Android Manifest file is not there, build and run works perfect. When I put it in the Android catalogue (which already contains Firebase) the app builds successfully, but won’t install I’m a bit desperate…
Thank you, already did it, works like a charm Anyway, I have last question haha Sorry for bothering you so much
I wanted to ask you about the best way to save the photo. I mean I have the code to save it on Android but it doesn’t work in this case.
I managed to solve it by writing this function (where _imgPath = path). Hope it will help someone in the future :):
public void QuickSave(){
if(!String.IsNullOrEmpty(_imgPath)) {
imgBytes = File.ReadAllBytes(_imgPath);
cacheTexture = new Texture2D(2, 2);
cacheTexture.LoadImage(imgBytes);
SaveImageToGallery(cacheTexture, “testCache”, “test”);
}
}
Anyway, this solution is pretty simple and clean, but a bit slow
Or, you can simply copy the image at “path” to wherever you want via File.Copy. Nothing else can beat its speed. And you should use Path.Combine(dirPath, “Image.png”) to create paths, otherwise you’ll have to handle / and \ characters manually.
Another thing that I can’t wrap my mind around is it seems to be impossible to adjust the aspect ratio of the image to the texture.
Works in every single scenario besides this:
Hi! I was testing a little bit with the Quality parameter of the RecordVideo. It doesn’t seem to change much, and the size of the video stays pretty much the same. Is this something that the device camera settings can override?
Some Android camera apps (even built-in camera apps) may not respect the parameters NativeCamera sends to them like quality, video length and etc. It is out of my control, unfortunately. So you shouldn’t 100% rely on them.
Hi yasirkula!
First of, thank you for all of your work not just this one, all are very useful!
I have few questions regarding NativeCamera:
Is there a way to take more than just one photo when Camera app is opened? Because, after one photo is shot, there is “retry” and “ok”. It would be great if there is possibility to shot photos as user want, then save them (example, with your NativeGallery to gallery) and when user is done with shooting there is a button to go back to Unity app (I know its impossible to put overlay on Camera app, but back button is enough for now).
I tried your example script with your NativeGallery and in Android build (I didn’t tried iOS build yet) images are rotated 90 degrees counterclockwise, is there are way to fix it that I missed inside these plug-ins?
It is not possible, sorry. I have no control over the native camera app, even the screen with the retry and OK buttons is shown by the camera app. I regain control only after the camera is closed entirely. You’ll have to call TakePicture continuously inside TakePicture’s callback until the path is null (camera is closed with back button).
If you are loading the image via LoadImageAtPath, that is not the expected behaviour. I think it is the first time I’m hearing about this issue on Android, though. Is this behaviour persistent across all your test devices?
Oh that’s a real bummer. I have to think something out, it wont be user friendly if user have to tap accept for every photo (and user will have to make around 30 photos in my app). Thats a real bummer…
Update for this problem. I tried on another device and it works fine as it should. So, on Xiaomi Mi 9T works fine, on Samsung S8 Plus is were the problem happens. Just so you know, the problem isn’t on quad in front of the camera (talking about your example script), it happens when you save it to gallery.
For 1), you’ll have to use a plugin that displays camera feed directly inside Unity and also supports capturing a photo with the camera. For example, this plugin might work for you but I haven’t tried it myself, so no guarantees.
There are two SaveImageToGallery overloads: one takes “string path” parameter and the other takes “Texture2D texture” parameter. Can you try using the one you are not currently using and see if it changes anything? And for reference, which Android OS is your S8+ running on?