0 votes

Greets! How to have a round button please? Meanin to shape it so that its 'selection zone' is round instead of the preset square?

in Engine by (321 points)

are you using 3.0?

Indeed. But since a few days.

1 Answer

0 votes

Not possible with just GDScript afaik. But a workaround is not that hard.

Define a CollisionPolygon. Then in the insepctor for it, you set "Pickable" to true. This way you will get input events when you click on the shape, which you can catch with

func _input_event( Object viewport, InputEvent event, int shape_idx ):
    if shape_idx == idx_of_your_shape:
by (840 points)

Great, so no need of a button node?

I advise you to have a look into creating plugins. You can create your own customnodes, for example a "customshape_button", which will be available from add node in the editor at the end of the process. But yeah, for that case, no button is needed. But, you could put that shape under a button of course and have it's input change the button...

Ok, thxs, I'll try that. Cause the collisionpolygon don't have text nor is pickable eh.

Well, it IS pickable if you set the pickable flag to true. :D Remember that due to Godot's great node system, you can easily make textures and labels children of the collision shape! :)

I used a sprite for the texture of the collisionpolygon, but there's neither text so I have to script the 'print' somehow? Isn't there a node to connect that makes that, printin a text in our font choice with big leters?

Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to webmaster@godotengine.org with your username.