- Home /
Imported FBX causing problems
Hello, I am new to unity. So I have a model imported as FBX and an another one as 3ds, I created 2 prefabs and put each model in a prefab. I have a script that changes the cursor on mouse over using the function OnMouseEnter(). The script didn't work, but when I tried the script attaching to a cube, it changes the cursor. Why does the imported models cause this problem while the primitive shapes created by unity don't?
Answer by kolban · Jun 01, 2012 at 03:56 AM
Have a look at the documentation on OnMouseEnter() found here:
http://unity3d.com/support/documentation/ScriptReference/MonoBehaviour.OnMouseEnter.html
You will see that OnMouseEnter() detects the mouse passing over an object which has an associated Collider. When you created a Cube object, Unity gives it a Collider by default. When you import your externally modeled assets, they are not given a default Collider. As such, when you mouse over them and they have no associated collider, the OnMouseEnter callback is simply not invoked.
The quickest solution is to add Collider components to each of your imported models.
if you add a capsule collider for example , you have to set the settings in the inspector like the height,radius and height, or else it will catch the mouse on the volume where the collider is. So try to fit the collider to your model and often avoid mesh colliders unless nessecasry
Well thank you all, it works with a capsule or box collider and doesn't work with a mesh collider! what might be the reason?
If you add your mesh collider and then ask for the renderer to be temporarily disabled, do you see the green collider wire frame where you expect it to be?
Your answer
