File tree Expand file tree Collapse file tree 2 files changed +13
-5
lines changed
simple_nodes/simple_character Expand file tree Collapse file tree 2 files changed +13
-5
lines changed Original file line number Diff line number Diff line change @@ -14,14 +14,20 @@ func _ready():
1414 _update_parent_script ()
1515
1616
17+ func _get_custom_or_native_class (node : Node ):
18+ if node .has_method ("get_custom_class" ):
19+ return node .get_custom_class ()
20+ return node .get_class ()
21+
22+
1723func _enter_tree ():
1824 if not Engine .is_editor_hint ():
1925 return
2026
2127 # Create script
2228 if bsd == null :
2329 var new_bsd : BlockScriptData = load ("res://addons/block_code/ui/bsd_templates/default_bsd.tres" ).duplicate (true )
24- new_bsd .script_inherits = get_parent (). call ( "get_class" ) # For whatever reason this works instead of just .get_class : )
30+ new_bsd .script_inherits = _get_custom_or_native_class ( get_parent ())
2531 new_bsd .generated_script = new_bsd .generated_script .replace ("INHERIT_DEFAULT" , new_bsd .script_inherits )
2632 bsd = new_bsd
2733
@@ -44,6 +50,8 @@ func _update_parent_script():
4450
4551
4652func _get_configuration_warnings ():
47- if bsd :
48- if get_parent ().call ("get_class" ) != bsd .script_inherits :
49- return ["The parent is not a %s . Create a new BlockCode node and reattach." % bsd .script_inherits ]
53+ var warnings = []
54+ if bsd and _get_custom_or_native_class (get_parent ()) != bsd .script_inherits :
55+ var warning = "The parent is not a %s . Create a new BlockCode node and reattach." % bsd .script_inherits
56+ warnings .append (warning )
57+ return warnings
Original file line number Diff line number Diff line change @@ -9,7 +9,7 @@ func _ready():
99 $ Sprite2D .texture = sprite_texture
1010
1111
12- func get_class ():
12+ func get_custom_class ():
1313 return "SimpleCharacter"
1414
1515
You can’t perform that action at this time.
0 commit comments