unity3d - How to handle click on object? -
i've tried examples of code handle click on object, don't work.
i have object's mesh on scene:
on main camera there 1 c# script component code:
using unityengine; using system.collections; public class cameraanim3 : monobehaviour { void update() { if (input.getmousebuttondown (0)) { // if left button pressed... print ("cli!!!"); // create ray passing through mouse pointer: ray ray = camera.main.screenpointtoray (input.mouseposition); raycasthit hit; if (physics.raycast (ray, out hit)) { // if hit... print ("clicked on object!!!"); // if must // selected item, here, // select new one: transform selected = hit.transform; selected.gameobject.setactive (true); print (selected.gameobject.name); // whatever want newly selected // object } } } }
when clicked left button on mesh of head, in console message "cli!!!" showed, no message "clicked on object!!!" showed.
how catch click on mesh?
Comments
Post a Comment