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..fe4f189 100644 --- a/addons/hide_private_properties/inspector_plugin.gd +++ b/addons/hide_private_properties/inspector_plugin.gd @@ -1,6 +1,11 @@ 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 + var scene_path: Variant = object.get("scene_file_path") return scene_path != null && scene_path != "" && object != EditorInterface.get_edited_scene_root() @@ -8,3 +13,11 @@ 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: + # 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 + 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"