- Home /
How to turn on camera light (make a flashlight) on iPhone/iPad?
Hi everyone,
I was wondering if I can turn on camera light on my iPhone? Does Unity support that kind of action?
I found something about that on the internet, but they don't explain anything about the process or java scripting in unity, and i also didn't find anything in script references.
Thanks
I sent e-mail to people from prime31 and i'll see what they say... I know that this subject is very advanced, but i'll have to learn it eventually :) Thanks for the advice!
Answer by whydoidoit · Jun 20, 2012 at 09:49 PM
Vuforia's CameraDevice supports turning on the camera light on the iPhone, ut might be a bit of overkill :) - But it is free.
Hey $$anonymous$$ike, i downloaded that plugin and it has lots of stuff, so i will see if i can "isolate" only what i need. When I get to my answer I will post it on this topic! Sorry about the iPad in my question, it was "automatic mistake" :)
Thanks a lot for your help, this forum has always been most helpful!
It's CameraDevice.Instance.SetFlashTorch$$anonymous$$ode(true); :)
$$anonymous$$ike, I just spent a lot of time reading all of those scripts that i downloaded. In my project I used only two of them, one is CameraDevice that is attached to $$anonymous$$ain Camera. I took only this: bool result = cameraDeviceSetFlashTorch$$anonymous$$ode(on ? 1 : 0) != 0; )
And second is, very short, QCAR$$anonymous$$acros for platforms. I made simple ON/OFF button.
I built it and the build succeeded, but it just won't run it on my iPhone. It says:
Unable to resolve pinvoke method 'CameraDevice:cameraDeviceSetFlashTorch$$anonymous$$ode (int)' Re-run with $$anonymous$$ONO_LOG_LEVEL=debug for more information.
Do you now what else should I add in my project, maybe some .dll file, i don't know?
P.S. I didn't use "Instance" cause it kept giving me error. So I put together everything in one script.
Thanks!
Hmmm, that's odd - sometimes QCAR has a problem with the update of your XCode project (especially if you use it with some other plugins). I have to say I haven't tried it in a few months. If you IOS project is building - perhaps it's broken in Vurforia...
I managed to make it work! I just had to import much more scripts in my project 'cause they all depend on each other.
Thanks a lot $$anonymous$$ike for the link, Vuforia package really has everything for the camera, zoom, focus, torchlight...
Thanks!!!
Answer by hellobard · Sep 12, 2012 at 09:52 PM
Hey Milena, Could you possible share how you set up the button on / off and called up the Qualcomm script? bit of a noob here, but I'd love to learn from how you made it work!
just wanted to add to this thread if anyone else should be in use of this information like I did:
To make this work, I had to put the Qualcomm Vuforia folder of the project into my Plugins folder to make the script accessible through JS. I then used FingerGestures (in my case) with a function OnTap and just added this line of code: CameraDevice.Instance.SetFlashTorch$$anonymous$$ode(true);
Works perfectly on iOS. Will have to try this on Android too.
Could you please tell me, where can I get that Qualcomm Vuforia, as I know right now you need to get the plugin so you can use CameraDevice.Instance.SetFlashTorch$$anonymous$$ode(true); right? $$anonymous$$uch appreciate and thank you very much in advance!
Your answer
Follow this Question
Related Questions
How to turn on camera light on iPhone? 0 Answers
iPhone StoreKit implementation problem 2 Answers
GameObjects appear different on device than on Unity3d Player 2 Answers
How do you make an iPhone Game with Unity? 4 Answers
iPad touch scripting... 0 Answers