Game Development Stack Exchange is a question and answer site for professional and independent game developers. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I've just started to learn Unity3D.

I want to create a simple 3D menu with just two 3D Text instances. I've created and named them, then dropped this script:

function Awake(){
    print("MenuItem "" init!");
function OnMouseEnter(){
    print("OnMouseEnter " +;
function OnMouseDown(){
    print("OnMouseDown " +;

I only see the init/awake message printed in the console.

What am I missing ?


Sorry, I forgot to add the BoxCollider(Physics>Box Collider) to my object, so no events were triggered.

share|improve this question
up vote 4 down vote accepted

First make sure that everything else is set up correctly.

In a different script that's running somewhere, put in this bit of code (C#, and from memory so it may not be 100% accurate):

RaycastHit hitInfo;
if( Physics.Raycast( Camera.main.ScreenPointToRay( Input.mousePosition ), out hitInfo ) )
    Debug.Log( "mouse is over object " + );

If that doesn't work then you probably don't have your colliders set up correctly. If it does print out something then you have something else messed up.

share|improve this answer
ScreenPointToRay look handy, thanks! what dows the out keyword do ? – George Profenza Oct 7 '10 at 19:55

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.