Search Unity

How Do I Make a Toggle Button To Turn The Phone Camera Flashlight On/Off?

Discussion in 'AR/VR (XR) Discussion' started by Aarlington, Mar 12, 2019.

  1. Aarlington

    Aarlington

    Joined:
    Jul 8, 2018
    Posts:
    11
    I'm having a bit of trouble here, can someone assist me?

    Thanks in advance!
     
  2. Aarlington

    Aarlington

    Joined:
    Jul 8, 2018
    Posts:
    11
    Anyone with an answer? I want to make a button within the AR Camera that can turn camera flashlight on/off.
     
  3. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
  4. Aarlington

    Aarlington

    Joined:
    Jul 8, 2018
    Posts:
    11
    Thanks!
     
  5. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    Replying to the private message you sent me here so others can benefit from it:

    "So I got the asset, how do I go about making a script that makes a button within the ARCamera scene that toggles the flashlight? Any chance you can help or point in me in the right direction."

    Your probably better off contacting the developer of the asset, I dont own the asset.

    But it sounds like a simple task, have you followed any of the unity UI tutorials? Should just be a case of make a UI screenspace canvas, add a button to it, then hook up the "enable" or "disable" method to the button click handler via the inspector.

    If you want to toggle, you can create 2 buttons, one that is "on" and one that is "off" and then have the on button click handler also disable itself and enable the off button. Have the off button disable itself and enable on button. You now have a toggle button.
     
    Aarlington likes this.
  6. Aarlington

    Aarlington

    Joined:
    Jul 8, 2018
    Posts:
    11
    Still having issues with this, am I suppose to pull permissions first?
     
  7. MadeFromPolygons

    MadeFromPolygons

    Joined:
    Oct 5, 2013
    Posts:
    3,983
    Im not sure what you meant by that, also have you contacted the asset author? I am not the author nor do I own the asset so I cant help much on this matter