Skip to content

Instantly share code, notes, and snippets.

@xsellier
Created February 7, 2020 19:24
Show Gist options
  • Save xsellier/743ba1f214ab89259c8b2ac338670dc2 to your computer and use it in GitHub Desktop.
Save xsellier/743ba1f214ab89259c8b2ac338670dc2 to your computer and use it in GitHub Desktop.
Debug les signaux de Godot Engine
extends Node
# ' emit_signal\(([^\n]+)*\)'
# ' debug_manager.emit_signal_debug(self, [\1])'
# ' ([^\s]+)\.emit_signal\(([^\n]+)*\)'
# ' debug_manager.emit_signal_debug(\1, [\2])'
var new_frame = true
var signals = {}
func _ready():
while true:
yield(get_tree(), 'idle_frame')
new_frame = true
func emit_signal_debug(context, parameters = []):
if new_frame:
print(signals)
print('=========== NEW FRAME =========== ')
signals = {}
if not signals.has(parameters[0]):
signals[parameters[0]] = 1
else:
signals[parameters[0]] += 1
new_frame = false
context.callv('emit_signal', parameters)
var signal_depth = 0
var current_stack = get_stack()
for item in current_stack:
if item.function == 'emit_signal_debug':
signal_depth += 1
if signal_depth > 1:
print('============================')
print('signal name: %s' % [parameters[0]])
for item in current_stack:
if item.function == 'emit_signal_debug':
print('=> %s (%s:%s)' % [item.function, item.source, item.line])
else:
print('-> %s (%s:%s)' % [item.function, item.source, item.line])
print('============================')
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment