Godot Version
4.4
Question
How can i refresh the visual shader editor to show my newly added floatconstant node which was added through my button panel?
Right now i am adding the node, but to refresh the ui to show it to me, i need to close and reopen the visual shader editor. I need a programmatic way.
func add_float_constant():
print("[Plugin] add_float_constant() called")
var shader := get_target_visual_shader()
if shader == null:
print("[Plugin] No VisualShader found")
return
print("[Plugin] VisualShader found:", shader)
var node := VisualShaderNodeFloatConstant.new()
node.constant = 1.0
var graph_type := VisualShader.TYPE_FRAGMENT
var node_id := shader.get_valid_node_id(graph_type)
shader.add_node(graph_type, node, Vector2(200, 200), node_id)
shader.connect_nodes(VisualShader.TYPE_FRAGMENT, node_id, 0, 0, 0)
shader.emit_changed()