How to attach a button to a gameobject in 2d?

Hi, I have a script which generates random prefabs of gameobjects, is there a way to attach a GUI Button to each of the generated gameobjects, I have been trying but I can’t find a way to do it, thanks for your help :slight_smile:

by the way those objects are moving.

Yes we need a little more information here before we can help you. But if you want a button to appear when a prefab is generated, you can just attach a script to the prefab that has an OnGUI function in it to draw the button.