Skip to content

Commit

Permalink
[merge] Fix property not found warning in Hide Private Properties
Browse files Browse the repository at this point in the history
  • Loading branch information
IceflowRE authored Feb 21, 2024
2 parents b922d7e + da066ab commit a104a38
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
13 changes: 13 additions & 0 deletions addons/hide_private_properties/inspector_plugin.gd
Original file line number Diff line number Diff line change
@@ -1,10 +1,23 @@
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()

func _parse_property(object: Object, type: Variant.Type, name: String, hint_type: PropertyHint, hint_string: String, usage_flags: int, wide: bool) -> bool:
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
2 changes: 1 addition & 1 deletion addons/hide_private_properties/plugin.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down

0 comments on commit a104a38

Please sign in to comment.