Hi all,
am having one cube object and have attached move script to cube.I have added this cube as prefab.
Dynamically am creating object for cube prefab. Onmouse click i have to find out which cube i have clicked.
if(Input.GetMouseButton(0)||Input.GetMouseButton(1))
{
var ray = Camera.main.ScreenPointToRay(Input.mousePosition);
var hit : RaycastHit;
if(Physics.Raycast(ray, hit))
{
var hitobjname=hit.collider.gameObject.name;
if(hitobjname==“Cube(Clone)”)
{
print(“action…”);
}
}
}
The above code is always entering into loop without touch the cube also…
How to do the best way…
Thanks