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");
}
}
}
}
Although true, this path is only known by the application instance from inside Unity. Third party tools, launchers, patchers, and middleware may not be able to correctly guess the path. And there are many cases where this is not the right solution. Sometimes it is required for the application to be aware of its current root structure in terms of the root binary executable. However, the OP was seeking for it to go side-by-side with the executable / player package, not sure this addresses the question.
– lloydsummers