From 755eb943a6dd9fb336fe0acecc6a6d9b989fd5f8 Mon Sep 17 00:00:00 2001 From: Shomy <61943525+shomykohai@users.noreply.github.com> Date: Fri, 19 Jul 2024 21:37:06 +0200 Subject: [PATCH] Fix script loading with Godot 4.3 Fixes various issue that came from Godot 4.3 changes in GDScript and loading: #196 #187 --- addons/pandora/model/type.gd | 8 ++++++-- addons/pandora/util/script_util.gd | 2 +- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/addons/pandora/model/type.gd b/addons/pandora/model/type.gd index 3a43d41..253c47d 100644 --- a/addons/pandora/model/type.gd +++ b/addons/pandora/model/type.gd @@ -73,8 +73,12 @@ static func lookup(name: String) -> PandoraPropertyType: if ResourceLoader.exists(type_path): var ScriptType = load(type_path) - if ScriptType != null and ScriptType.has_source_code(): - return ScriptType.new() + if ScriptType != null: + if Engine.is_editor_hint() and ScriptType.has_source_code(): + return ScriptType.new() + else: + if ScriptType.can_instantiate(): + return ScriptType.new() return UndefinedType.new() diff --git a/addons/pandora/util/script_util.gd b/addons/pandora/util/script_util.gd index 56f7112..995aded 100644 --- a/addons/pandora/util/script_util.gd +++ b/addons/pandora/util/script_util.gd @@ -39,7 +39,7 @@ static func create_entity_from_script( static func _get_entity_class(path: String) -> GDScript: var EntityClass = load(path) - if EntityClass == null: + if EntityClass == null or not EntityClass.can_instantiate(): push_warning("Unable to find " + path + " - defaulting to PandoraEntity instead.") EntityClass = PandoraEntityScript return EntityClass