I currently have the following script, and I want it to be so that when I click on a game object, it should show a button in my GUI. But, currently the button doesn’t show up when clicking on the gameObject. While the function itself works when I add a Debug.Log, it will return the right value.
function OnGUI () {
if (Input.GetMouseButton(0)) {
ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit: RaycastHit;
if (Physics.Raycast(ray, hit) && Input.GetMouseButtonDown(0) && hit.transform.tag == "component") {
if(GUI.Button (Rect (Screen.width - 120,130,100,25), "Delete")) {
//DeleteObject();
}
}
}
}