From efb0923d26a37a6621d0c2091f1cb8c6292cc1ec Mon Sep 17 00:00:00 2001 From: JostMK Date: Mon, 19 Feb 2024 22:11:23 +0100 Subject: [PATCH 1/2] [plugin] Fix property not found warning --- README.md | 4 ++++ addons/hide_private_properties/inspector_plugin.gd | 9 +++++++++ addons/hide_private_properties/plugin.cfg | 2 +- 3 files changed, 14 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 4f715b1..3c9c3a9 100644 --- a/README.md +++ b/README.md @@ -202,6 +202,10 @@ This plugin will hide exported private properties in the inspector for instantia ### Changelog +#### 1.1.2 + +- Fix: property not found warning + #### 1.1.1 - Use absolute paths in preloads diff --git a/addons/hide_private_properties/inspector_plugin.gd b/addons/hide_private_properties/inspector_plugin.gd index 9bae842..96fbd56 100644 --- a/addons/hide_private_properties/inspector_plugin.gd +++ b/addons/hide_private_properties/inspector_plugin.gd @@ -1,6 +1,9 @@ extends EditorInspectorPlugin func _can_handle(object: Object) -> bool: + if not _has_property(object, "scene_file_path"): + return false + var scene_path: Variant = object.get("scene_file_path") return scene_path != null && scene_path != "" && object != EditorInterface.get_edited_scene_root() @@ -8,3 +11,9 @@ func _parse_property(object: Object, type: Variant.Type, name: String, hint_type if name.begins_with("_"): return true return false + +func _has_property(object: Object, propertyName: String) -> bool: + for property in object.get_property_list(): + if property.name == propertyName: + return true + return false diff --git a/addons/hide_private_properties/plugin.cfg b/addons/hide_private_properties/plugin.cfg index 6b40d9a..dfea8fb 100644 --- a/addons/hide_private_properties/plugin.cfg +++ b/addons/hide_private_properties/plugin.cfg @@ -3,7 +3,7 @@ name="Hide Private Properties" description="Hide exported private properties in the inspector for instantiated child scenes." author="Iceflower S" -version="1.1.1" +version="1.1.2" script="plugin.gd" license="MIT" repository="https://github.com/kenyoni-software/godot-addons" From da066abe58112391b176800ae7f55e87b3cb0279 Mon Sep 17 00:00:00 2001 From: JostMK Date: Wed, 21 Feb 2024 00:25:17 +0100 Subject: [PATCH 2/2] [doc] Add explanation for property check --- addons/hide_private_properties/inspector_plugin.gd | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/addons/hide_private_properties/inspector_plugin.gd b/addons/hide_private_properties/inspector_plugin.gd index 96fbd56..fe4f189 100644 --- a/addons/hide_private_properties/inspector_plugin.gd +++ b/addons/hide_private_properties/inspector_plugin.gd @@ -1,6 +1,8 @@ extends EditorInspectorPlugin func _can_handle(object: Object) -> bool: + # Early return if property does not exist, prevents triggering a warning for + # some objects that overwrite the 'get' method. if not _has_property(object, "scene_file_path"): return false @@ -13,6 +15,8 @@ func _parse_property(object: Object, type: Variant.Type, name: String, hint_type return false func _has_property(object: Object, propertyName: String) -> bool: + # Note: Checking if the property exists using the 'in' keyword also triggers + # the warning in 'core/config/project_settings.cpp:_get' (v4.2.1) for property in object.get_property_list(): if property.name == propertyName: return true