using System;
using System.Collections;
using UnityEngine;
using UnityEngine.UI;
using System.Collections.Generic;
using Vuforia;
public class FlashlightButton : MonoBehaviour {
IEnumerator Start()
{
yield return new WaitForSeconds(2);
hasTorch = CameraDevice.Instance.SetFlashTorchMode(true);
yield return new WaitForSeconds(0.000f);
CameraDevice.Instance.SetFlashTorchMode(false);
}
bool torchState = false, hasTouch = false;
private bool hasTorch;
void OnGUI()
{
if (hasTorch)
{
if (GUI.Button(new Rect(0, 0, 170, 140), "Torch"))
{
torchState = !torchState;
CameraDevice.Instance.SetFlashTorchMode(torchState);
}
}
}
我希望在对该脚本进行多次修改之后,可以在Unity.GUI按钮中获得on Click动作,但是不幸的是,我无法弄清楚如何为Unity按钮UI创建on Click动作。
我尝试创建一个bool变量,即使尝试了许多变体,我仍然无法使脚本在Unity按钮UI上具有on Click变量。