@@ -53,6 +53,8 @@ var _execution_blackboard:BTBlackboard
53
53
var _execution_start_time_ms :float
54
54
var _execution_stop_time_ms :float
55
55
56
+ @onready var _performance_monitor_identifier :String = "BTRoot/%s -%s " % [get_name (), get_instance_id ()]
57
+
56
58
# ------------------------------------------
57
59
# Fonctions Godot redéfinies
58
60
# ------------------------------------------
@@ -69,7 +71,9 @@ func _ready() -> void:
69
71
_blackboard = BTBlackboard .new ()
70
72
71
73
if not Engine .is_editor_hint ():
72
- Performance .add_custom_monitor ("BTRoot/%s -%s " % [get_name (), get_instance_id ()], _compute_last_exec_time )
74
+ _add_custom_performance_monitor ()
75
+ tree_entered .connect (_add_custom_performance_monitor )
76
+ tree_exited .connect (_remove_custom_performance_monitor )
73
77
74
78
func _process (delta :float ) -> void :
75
79
if not Engine .is_editor_hint () and enabled and root_process_mode == BTRootProcessMode .PROCESS :
@@ -133,6 +137,13 @@ func _do_execute(delta:float):
133
137
_previous_running_nodes = running_nodes
134
138
_register_execution_stop ()
135
139
140
+ func _add_custom_performance_monitor () -> void :
141
+ if not Performance .has_custom_monitor (_performance_monitor_identifier ):
142
+ Performance .add_custom_monitor (_performance_monitor_identifier , _compute_last_exec_time )
143
+
144
+ func _remove_custom_performance_monitor () -> void :
145
+ if Performance .has_custom_monitor (_performance_monitor_identifier ):
146
+ Performance .remove_custom_monitor (_performance_monitor_identifier )
136
147
137
148
func _register_execution_start () -> void :
138
149
_execution_start_time_ms = Time .get_ticks_msec ()
0 commit comments