Make 4 buttons do something on hover without connecting a signal for each one?

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By tobycat

How do I make it so every button under my control node automatically plays a sound when hovered over, without connecting every single signal?

I have a control, under that is a Container, then my 4 buttons. I already have a function for instancing new sounds, i just need a way to make a sound play when hovering over them without having to connect signals to every one.

:bust_in_silhouette: Reply From: magicalogic

How about you make the button a scene. Then you just add a single script to the button scene and you can instance it however many times you need without reconnecting any signals every time.

:bust_in_silhouette: Reply From: tobycat

I found a solution to this! I think it’s pretty alright.

The Solution

The only problem I may have is, if I want to put anything else under that container, I’ll have to change the code a bit to check if a button. For now though, it works great.