- Home /
Assign mouse events for gameobject/collider at runtime
Hi
I have a gameobject created at runtime, is there any way to assign the the OnMouseEnter dynamically (without having a pre-written script), so the evens can be handled by a global script?
Thanks Peter
Answer by Jan Helleman · Jul 12, 2011 at 10:00 PM
What you could do is add a script to the game object which has a C# delegate function in it. The gameobject creating this object + script then adds itself to the delegate trigger. The scripts onMouseEnter script fires the delegate instead of running custom code.
but you didn't want to attach a script to it.
Your answer
Follow this Question
Related Questions
Camera movement question 1 Answer
Best way to transition one mesh to another with the option to change the target mesh 0 Answers
Activate 2 separate OnClick events, with the different Mouse Buttons 2 Answers
grab all game objects with a distance of the object? 2 Answers
Get button under mouse 1 Answer