@@ -4,6 +4,7 @@ extends EditorPlugin
44const BeehaveEditorDebugger := preload ("debug/debugger.gd" )
55var editor_debugger : BeehaveEditorDebugger
66var frames : RefCounted
7+ var _custom_types : Array [StringName ] = []
78
89
910func _init ():
@@ -33,7 +34,29 @@ func _enter_tree() -> void:
3334 else :
3435 frames = preload ("debug/old_frames.gd" ).new ()
3536 add_debugger_plugin (editor_debugger )
37+ _register_custom_types ()
3638
3739
3840func _exit_tree () -> void :
41+ _unregister_custom_types ()
3942 remove_debugger_plugin (editor_debugger )
43+
44+
45+ func _register_custom_types () -> void :
46+ # Some users report the script-class cache randomly missing BeehaveTree,
47+ # which makes the editor return a null instance. Register the type manually
48+ # so the node is still available even if the cache is broken.
49+ var tree_script : Script = load ("res://addons/beehave/nodes/beehave_tree.gd" )
50+ if tree_script == null :
51+ push_warning ("Beehave: failed to load BeehaveTree script; custom type not registered." )
52+ return
53+
54+ var tree_icon : Texture2D = load ("res://addons/beehave/icons/tree.svg" )
55+ add_custom_type ("BeehaveTree" , "Node" , tree_script , tree_icon )
56+ _custom_types .append (& "BeehaveTree" )
57+
58+
59+ func _unregister_custom_types () -> void :
60+ for type_name in _custom_types :
61+ remove_custom_type (type_name )
62+ _custom_types .clear ()
0 commit comments