Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Wolchy |
Hi everyone!
I create a UI for my game and would like that some buttons have a blue outline stroke when during a hover.
For this, I made a shader and added the set of buttons into the group “hasBlueStroke”. Next, I wrote this code in my script which rules the UI:
func _connect_blue_outline_shader():
var nodesHasOutlineStroke = get_tree().get_nodes_in_group("hasBlueStroke");
for node in nodesHasOutlineStroke:
node.connect("mouse_entered", self, "_set_outline_shader_material");
node.connect("mouse_exited", self, "_reset_outline_shader_material");
pass
pass
func _set_outline_shader_material():
self.material = outlineShaderMaterial;
pass
func _reset_outline_shader_material():
self.material = null;
pass
Resource of “outlineShaderMaterial” added at the title of script like onready.
I see that this resource and script work correctly in the debugger. I mean the resource is right and actions with mouse_entered and mouse_exited work well. But in run time the outline stroke is not displayed.
At the same time, if I assign material to each button separately, everything works great.
Earlier I wrote a similar code for connecting sounds to buttons. It is in the same script that governs the interface and works very well:
var nodesNeedButtonHoverRing = get_tree().get_nodes_in_group("hasRingingSoundHover");
for node in nodesNeedButtonHoverRing:
if !node.is_connected("mouse_entered", self, "play_button_hover_ring"):
node.connect("mouse_entered", self, "play_button_hover_ring")
pass
Any ideas?
I’m new in Godot and would appreciate any help. Have a nice day, everyone!