• Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
  • Asset Store
  • Get Unity

UNITY ACCOUNT

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account
  • Blog
  • Forums
  • Answers
  • Evangelists
  • User Groups
  • Beta Program
  • Advisory Panel

Navigation

  • Home
  • Products
  • Solutions
  • Made with Unity
  • Learning
  • Support & Services
  • Community
    • Blog
    • Forums
    • Answers
    • Evangelists
    • User Groups
    • Beta Program
    • Advisory Panel

Unity account

You need a Unity Account to shop in the Online and Asset Stores, participate in the Unity Community and manage your license portfolio. Login Create account

Language

  • Chinese
  • Spanish
  • Japanese
  • Korean
  • Portuguese
  • Ask a question
  • Spaces
    • Default
    • Help Room
    • META
    • Moderators
    • Topics
    • Questions
    • Users
    • Badges
  • Home /
avatar image
0
Question by Milena · Jun 20, 2012 at 02:09 PM · cameraiphonelightipad

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

Comment
Add comment · Show 1
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Milena · Jun 25, 2012 at 10:34 AM 0
Share

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!

2 Replies

· Add your reply
  • Sort: 
avatar image
2
Best Answer

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.

http://www.qualcomm.com/solutions/augmented-reality

Comment
Add comment · Show 6 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image Milena · Jun 25, 2012 at 10:38 AM 0
Share

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!

avatar image whydoidoit · Jun 25, 2012 at 10:56 AM 0
Share

It's CameraDevice.Instance.SetFlashTorch$$anonymous$$ode(true); :)

avatar image Milena · Jun 25, 2012 at 03:34 PM 0
Share

$$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!

avatar image whydoidoit · Jun 25, 2012 at 10:26 PM 0
Share

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...

avatar image Milena · Jun 26, 2012 at 11:52 AM 1
Share

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!!!

Show more comments
avatar image
0

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!

Comment
Add comment · Show 2 · Share
10 |3000 characters needed characters left characters exceeded
▼
  • Viewable by all users
  • Viewable by moderators
  • Viewable by moderators and the original poster
  • Advanced visibility
Viewable by all users
avatar image hellobard · Dec 16, 2012 at 11:53 AM 0
Share

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.

avatar image BoatBest · Jan 14, 2017 at 08:56 AM 0
Share

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

Hint: You can notify a user about this post by typing @username

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Welcome to Unity Answers

The best place to ask and answer questions about development with Unity.

To help users navigate the site we have posted a site navigation guide.

If you are a new user to Unity Answers, check out our FAQ for more information.

Make sure to check out our Knowledge Base for commonly asked Unity questions.

If you are a moderator, see our Moderator Guidelines page.

We are making improvements to UA, see the list of changes.



Follow this Question

Answers Answers and Comments

7 People are following this question.

avatar image avatar image avatar image avatar image avatar image avatar image avatar image

Related Questions

How to turn on camera light on iPhone? 0 Answers

Can I use unity 3d as a component of UI in ipad app? 0 Answers

Codes / Scripts that will not work on iOS 1 Answer

unable to download & load particular scene in iPhone Project 2 Answers

iPhone StoreKit implementation problem 2 Answers

  • Anonymous
  • Sign in
  • Create
  • Ask a question
  • Spaces
  • Default
  • Help Room
  • META
  • Moderators
  • Explore
  • Topics
  • Questions
  • Users
  • Badges