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: alt text

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?

alt text

answer here unity: object not being detected raycast highlighting


Comments

Popular posts from this blog

php - failed to open stream: HTTP request failed! HTTP/1.0 400 Bad Request -

java - How to filter a backspace keyboard input -

java - Show Soft Keyboard when EditText Appears -