Updated Custom Runner

Added check to see if the setting exists, before setting it to prevent
over-writting.
Need to figure out if output is working or not, since not able to
clear() the RichTextLabel.
Changed launch parameters to use Remote Debug.  Need to ensure that
Debug > Keep Debug Server Open in order to use.
This commit is contained in:
Mario Steele 2026-03-10 10:29:46 -05:00
parent eb16b80134
commit f782cc32d4

View file

@ -6,7 +6,8 @@ var _play_icon: Texture2D
var _stop_icon: Texture2D
func _enter_tree() -> void:
ProjectSettings.set("application/run/custom_runner", "")
if not ProjectSettings.has_setting("application/run/custom_rinner"):
ProjectSettings.set("application/run/custom_runner", "")
ProjectSettings.add_property_info({
"name": "application/run/custom_runner",
"type": TYPE_STRING,
@ -25,7 +26,6 @@ func _exit_tree() -> void:
_runner_btn.queue_free()
_runner_btn = null
class RunnerButton:
extends Button
@ -34,6 +34,7 @@ class RunnerButton:
var _running_pid: int = -1
var _io: FileAccess = null
var _err: FileAccess = null
var _output: RichTextLabel = null
func _init() -> void:
_play = EditorInterface.get_editor_theme().get_icon(&"Play", &"EditorIcons")
@ -85,13 +86,16 @@ class RunnerButton:
var run_arguments := [
godot,
"--path", project,
"-d"
#"--remote-debug", "tcp://%s:%s" % [host, port],
#"--editor-pid", "%s" % pid,
#"--position", "320,-24",
#"--scene", main_scene
#"-d"
"--remote-debug", "tcp://%s:%s" % [host, port],
"--editor-pid", "%s" % pid,
"--position", "320,-24",
"--scene", main_scene
]
# --remote-debug tcp://127.0.0.1:6007 --editor-pid 3480813 --position 320,-24 --scene uid://2t2hslaaewee
if not _output: _output = _get_output()
if _output:
_output.clear()
print("Executing project with the following Command Line: %s %s" % [runner, run_arguments])
@ -117,12 +121,12 @@ class RunnerButton:
await get_tree().process_frame
var res := _read_io(_io, output)
if res != "":
print_rich(res)
#if res != "":
#print_rich(res)
res = _read_io(_err, err)
if res != "":
print_rich(res)
#if res != "":
#print_rich(res)
await get_tree().process_frame
var str := _read_io(_io, output)
@ -149,3 +153,15 @@ class RunnerButton:
buffer.clear()
buffer.append_array(leftover)
return part.get_string_from_utf8()
func _get_output() -> RichTextLabel:
return _find_output(get_tree().root)
func _find_output(current: Node) -> RichTextLabel:
if current is RichTextLabel and current.get_parent() and current.get_parent().get_parent() and current.get_parent().get_parent().name.begins_with("@EditorLog"):
return current
for c in current.get_children(true):
var r = _find_output(c)
if r:
return r
return null