Log in or register to post comments

[HELP] Device flash light

April 10, 2013 - 5:44pm #1

How to turn on and off device flash light using button ?

[HELP] Device flash light

October 18, 2017 - 1:56am #9

how to put that script please give me instruction

[HELP] Device flash light

October 10, 2013 - 2:47pm #8

@AlessandroB .. Thank you very much .. you saved me alot of search time

[HELP] Device flash light

October 10, 2013 - 1:26pm #7

This thread is about Unity, not native SDK.

Anyway, if you check the API reference, you'll see that you can use the setFlashTorchMode() method of the CameraDevice class.

https://developer.vuforia.com/resources/api/class_q_c_a_r_1_1_camera_device

 

 

 

[HELP] Device flash light

October 10, 2013 - 12:49pm #6

What if I'm using the native SDK with eclipse, not unity

can I turn the flash light ON/OFF through it ?

[HELP] Device flash light

June 12, 2013 - 1:34pm #5

Add it to a script that inherits from MonoBehaviour and then drop that script on to the ARCamera.

[HELP] Device flash light

June 12, 2013 - 3:20am #4

where input the code? brother...

[HELP] Device flash light

April 17, 2013 - 5:54pm #3

Thanks for your help, now my flashlight it's work

[HELP] Device flash light

April 10, 2013 - 6:09pm #2

Here you go..

        // Turn flash on or off.
        if (GUILayout.Button("Toggle Flash", 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;
            }

            mMenuToShow = MenuMode.MENU_OFF;
            mButtonPressed = true;
        }

 

That code can go in the OnGUI method of a script that inherits from MonoBehaviour, and you also need to add the following member variable to store the state of the flash so that it can be toggled..

    // Check if flash is currently enabled.
    private bool mFlashEnabled = false;

 

The button style can be defined as such..

        // Setup style for buttons.
        GUIStyle buttonGroupStyle = new GUIStyle(GUI.skin.button);
        buttonGroupStyle.stretchWidth = true;
        buttonGroupStyle.stretchHeight = true;

 

Log in or register to post comments