- Home /
How to trigger a object on Mouse Enter and Down?
I am a user of Unity3d 2.5. Now I import a FBX file which contain a phone and an animation in it. I would like to implement a effect that when mouse enter the phone, the phone moves.
So, I use OnMouseEnter() from the manual, but the object seems never trigger by any mouse event.Why, is that anything wrong to use an object not created by GameObject menu or something. Please let me know why the object didn't response to anything.
The process I do is: 1. Import the FBX file to Assets 2. Drag the object to the Scene 3. Drag the script write
function OnMouseEnter(){
print("I am Called");
}
The result is I get nothing. PS I am sure the script is assigned to the object.
Answer by 3dDude · Aug 07, 2010 at 04:27 PM
i think the object should have a collider.. in the FBX importer check "Generate colliders" and of that does not work you can try a boxCollider...... hope this helps!
Answer by Wolfram · Aug 07, 2010 at 04:27 PM
OnMouseEnter() needs a Collider to work. In the import settings of your FBX, check "create mesh colliders". Or, if it's a very complex model and you don't need exact matching you can approximate the shape of your mesh by adding a number of Colliders within Unity.