hello,
I want to make a simple switch to enable or disable UI buttons by clicking on any gameObject. (Using Unity 5.3.5).
I have multiple objects in my game view,and there are separate UI buttons inside the canvas for each of the object.
Whenever I click or touch on any object it will show the UI related to that object.
using the code bellow i am able to click only on Single object (there is also no touch input), i want to add multiple objects with UI switch…
How to write it inside this code… please help
using UnityEngine;
using System.Collections;
using UnityEngine .UI;
public class click1object : MonoBehaviour {
void Start () {
}
void Update(){
if (Input.GetMouseButtonDown(0)){ // if left button pressed...
Ray ray = GetComponent<Camera>().ScreenPointToRay(Input.mousePosition);
RaycastHit hit;
if (Physics.Raycast(ray, out hit)){
print ("clicked");
}
}
}
}