godot_osc_demo/UI.gd

24 lines
644 B
GDScript3
Raw Normal View History

extends Control
func _ready():
var scene = preload("res://osc_receiver.tscn")
var osc_server = scene.instantiate()
add_child(osc_server)
# configure all sensors
for i in range(4):
var nodename = "VSlider%d" % (i + 1)
var osc_addr = "/slider/%d/set" % i
var slider_node = find_child(nodename)
osc_server.register_callback(osc_addr, "f", slider_node.recv_osc)
for i in range(4):
var nodename = "Button%d" % (i + 1)
var osc_addr = "/button/%d/set" % i
var button_node = find_child(nodename)
osc_server.register_callback(osc_addr, "i", button_node.recv_osc)
# start listening for osc messages
osc_server.start_server()