Created
February 7, 2020 19:24
-
-
Save xsellier/743ba1f214ab89259c8b2ac338670dc2 to your computer and use it in GitHub Desktop.
Debug les signaux de Godot Engine
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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