- Home /
Instantiated prefab script not capturing on click
Hi! I have a prefab that when clicked, it just logs into the console that it was clicked. When I add it on the scene, the behavior works as expected. Since the prefab(obj2) is a hidden menu of another prefab (obj1), I instantiate a clone when obj1 is clicked. That part works, but, the onClick event on the menu does not work at all. So, the crow bar, has a script attached that handles on click events. In that scenario, it works. But, while on play, if I click on the shop, that same menu is cloned, and when clicking on the crow bar of the clone, nothing happens, the click event is lost. What am I doing wrong? Thanks!
I have tried adding the on click to the yellow area. It works, the issue looks like it is the collider, I have a poligon for the yellow area and a circle for the crowbar, apparently the poligon is taking all clicks when the prefab is instantiated.
Answer by unity_Mp42xUSNbdbHRw · Aug 15, 2018 at 02:28 AM
Found what I had wrong. The crowbar collider was overlapping the menu collider, and only one took precedence. It was mere luck that the non instantiated one worked.
Your answer
![](https://koobas.hobune.stream/wayback/20220612172809im_/https://answers.unity.com/themes/thub/images/avi.jpg)