as easy as this is and i know its going to be easy i can not find anything about this ive searched for hours and cant find anything that helps my situation.
i have created a UI button ( not from script) and i need to get it to change a bool value in a script.
i have the script added to this button but cant figure out how to get the click input for this button.
in new to unity and still have very novice skills.
Note, if you don’t already have one, you will need a collider on your button if you want this to work. Also, assuming you’re refering to mouse left click.
using UnityEngine;
using System.Collections;
public class buttonTest : MonoBehaviour {
void Update () {
if(Input.GetMouseButtonDown (0)){
Ray ray = Camera.main.ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast (ray, out hit, Mathf.Infinity)) {
if(hit.transform == transform) {
accessYourBoolHere;
}
}
}
}
}