- Home /
Question by
BunnyProductions · Apr 23, 2018 at 12:01 AM ·
torch
How to make a android flashlight using C#
How do I make the Android flashlight turn On/Off using only C#? I searched it up and didn't find any good tutorials. I am complete noob, so please make it easy to understand.
Code:
using System.Collections; using System.Collections.Generic; using UnityEngine; using UnityEngine.UI;
public class Everything : MonoBehaviour {
public Button mybutton;
public Text txt;
public bool On = false;
AndroidJavaObject Cam;
AndroidJavaClass cameraClass = new AndroidJavaClass("android.hardware.Camera");
// Use this for initialization
void Start () {
mybutton.onClick.AddListener (Action);
}
void Action ()
{
if (On)
{
txt.text = "On";
On = false;
TurnOff();
} else
{
txt.text = "Off";
On = true;
TurnOn();
}
}
void TurnOn()
{
}
void TurnOff()
{
}
}
Comment
Your answer
![](https://koobas.hobune.stream/wayback/20220612161317im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
How do you write a Pauseable-Timer Script in Unity JavaScript? 1 Answer
How do I make the player Blink? 1 Answer
Battery Pickup Regeneration 2 Answers
What is wrong with my torch script 1 Answer
How to use shuriken particle torch 1 Answer