- Home /
Question by
BAnimTech · Aug 06, 2013 at 08:27 AM ·
basicbasicsbasic programming
How to use GameObject like Button?
Hello :)
I'm new here, hence maybe the simple Q.
I have a very detailed GameObject, lets say a Car (.fbx file) composed of 10 small GameObjects.
My goal is to press on (mouse click, touch, whatever...) one of the components,
lets say the door handle (that is a GameObject too) and do something (not the issue here).
What are my options? What is the best/right approach?
Thanks :)
Comment
Best Answer
Answer by CHPedersen · Aug 06, 2013 at 08:36 AM
You can put a script on the child object that implements methods for the standard MonoBehavior mouse callbacks, see eg. OnMouseDown for how to catch mouse clicks. There are also similar methods for mouse over, mouse leave, etc.
For the callback to be called, the object must have a collider.