Topic locked

Toggle On/Off LED Light on iPhones?

March 18, 2014 - 2:21am #1

Hello,

 

My augmented realtiy app doesnt work that great in low key lighting, so I'm wondering if its possible to toggle the LED iphone light on and off? Is this something thats possible?

 

Thanks.

Toggle On/Off LED Light on iPhones?

March 19, 2014 - 6:02am #7

Excellent.

Toggle On/Off LED Light on iPhones?

March 19, 2014 - 3:40am #6

Okay, all done now - I just made a JavaScript to C# crossover script. Thanks!

Toggle On/Off LED Light on iPhones?

March 19, 2014 - 3:34am #5

You need to code in C#, as the Vuforia API is not available in Javascript.

Toggle On/Off LED Light on iPhones?

March 19, 2014 - 2:31am #4

Thanks,

When I put this within my script, I get an error saying "Unknown identifier : CameraDevice". I'm coding in JavaScript, will that make a difference?

 

Ollie

Toggle On/Off LED Light on iPhones?

March 18, 2014 - 2:50am #3

Yes, you can turn on/off the Flash (LED) by using the SetFlashTorchMode ( bool ) method of the CameraDevice class.

Just use this code in your scripts:

CameraDevice.Instance.SetFlashTorchMode( true );  // or false

 

Toggle On/Off LED Light on iPhones?

March 18, 2014 - 2:46am #2

HI Oliver ,

 

Try this works on my android but should work on IOS

using UnityEngine;
using System.Collections;
 
public class flashlight : MonoBehaviour {
public GUIStyle buttonGroupStyle;
public bool mFlashEnabled = false;

// Use this for initialization
void OnGUI()
{
// Setup style for buttons.

 
        
GUIStyle buttonGroupStyle = new GUIStyle(GUI.skin.button);
        
buttonGroupStyle.stretchWidth = true;
buttonGroupStyle.stretchHeight = true;
 
        
        
// Turn flash on or off.
if (GUI.Button(new Rect (45,20,150,50),"Flashlight", buttonGroupStyle))
            
 
{
if (!mFlashEnabled)
{
// Turn on flash if it is currently disabled.
 CameraDevice.Instance.SetFlashTorchMode(true);
        mFlashEnabled = true;
}
else
{
// Turn off flash if it is currently enabled.
CameraDevice.Instance.SetFlashTorchMode(false);
        mFlashEnabled = false;
}
     {
     
 
    
   

}
}
    }

Topic locked