0 votes

Some nodes can be used by properties or functions, to apparently perform the same effect. For example:

 get_node("Button1").disabled = true
 get_node("Button1").set_disabled(true)

Why ?
What is the difference?
One is better than the other?

in Engine by (33 points)

1 Answer

0 votes

Have a function gives you more control over what will happen when setting a value.

Your Button has BaseButton implementing disabled BaseButton

Setting disabled = false will call set_disabled(false) under the hood.

A more complex example is ie See ie is_active

var is_active = true setget set_is_active

when settings is_active = true will call set_is_active(true) under the hood.

func set_is_active(value):
    is_active = value
    set_physics_process(value)
    set_process_unhandled_input(value)
    set_block_signals(not value)

which is a complex action.

by (638 points)
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.