Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Fenisto |
I have several control nodes that via signals execute some code when I mouse click on them. Lets say they set a var value to 1 or 2 based on a node.
Can I somehow set this var for example to 0 by clicking outside of those node? Without making another control node or a collision area. Or mouse coordinates.
What about setting up a master node for all those nodes. Then, whenever one of them is clicked, they send a signal to the master node telling it which of them was clicked, and it changes the variable to whatever the corresponding value is (1, 2, etc.). If it detects a mouse click (via the normal Input.is_action_just_pressed
method), but doesn’t get any signal, it just changes it to the neutral value (0).
It’s a little sketchy though, there might be a better way to do it.
denxi | 2020-02-19 19:29
Thanks. A worthy idea. But what I’m doing supposed to have a lot of ui elements. Would need to add everything. But still works that way too I suppose.
Basically just need to make a full-pledged UI and not some separate pieces. Which needs to be done anyway
Fenisto | 2020-02-19 19:35
Solved it for my case by having a general input event and in it I change the var by a right click
func _input(event):
if Input.is_mouse_button_pressed(2):
var = 0
Fenisto | 2020-02-21 14:24