You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
48 lines
1.5 KiB
48 lines
1.5 KiB
@tool
|
|
extends EditorScript
|
|
|
|
var testButton: Button
|
|
|
|
func _run():
|
|
#var selected: Node = EditorInterface.get_inspector().get_child(0).get_child(2)
|
|
#_print_info(selected)
|
|
#print((EditorInterface.get_inspector().get_child(0).get_child(2).get_child(-1) as Button).text)
|
|
#print((selected as LineEdit).text)
|
|
#(selected as LineEdit).insert_text_at_caret("hello")
|
|
#(selected as LineEdit).text_changed.emit((selected as LineEdit).text)
|
|
#print(selected.get_class())
|
|
#print(is_instance_of(selected, EditorPropertyText))
|
|
#print(_find_recursive(selected,"EditorPropertyMultilineText")[0].get_child(0).get_child(0).get_class())
|
|
#print(_find_recursive(selected,"EditorPropertyText")[0].get_child(0).get_child(0).get_class())
|
|
testButton = Button.new()
|
|
testButton.text = "Remove this button"
|
|
#testButton.global_position = Vector2(1904.0, 305.0)
|
|
testButton.pressed.connect(
|
|
func():
|
|
testButton.get_parent().remove_child(testButton)
|
|
testButton.queue_free()
|
|
)
|
|
EditorInterface.get_base_control().add_child(testButton)
|
|
|
|
pass
|
|
|
|
|
|
func _print_info(node: Control):
|
|
print("Name: "+node.name)
|
|
print("Children:")
|
|
for child in node.get_children():
|
|
print(" - "+child.name)
|
|
|
|
func _find_recursive(node: Node, type: Variant) -> Array[Node]:
|
|
if type is String:
|
|
if node.get_class() == type:
|
|
return [node]
|
|
elif is_instance_of(node, type):
|
|
return [node]
|
|
|
|
var retval: Array[Node] = []
|
|
for child in node.get_children():
|
|
retval.append_array(_find_recursive(child, type))
|
|
return retval
|
|
|