GUI Button - what am I missing? (SOLVED)

Hi there,

I’m new to Defold Engine, so this might be a REEEEAALLY noob question.

I created a button with a simple GUI Script and attached to it.

function init(self)
    print('button initialized')
end

Added this button.gui to a main.gui as a template.
Added the main.gui to the main.collection.
But the print never happens! What I am doing wrong here?

To test if it was working, I put the button.gui directly inside main.collection and it worked. So the issue must be with the main.gui.

1 Like

Hi and welcome!

Unfortunately templates doesn’t use/run the attached script at all. You will need to add your interaction with the button to the gui scene that is using the gui template (in your case main.gui).

OK! Thanks

Here’s a hands-on example of a button as well. This asset might also be of interest.

Good luck!

2 Likes