Hide/Show exposed properties dynamically in tools

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By hearto
:warning: Old Version Published before Godot 3 was released.

Hello,

How do I hide/show exposed properties in tool nodes dinamically?.
For example a tool node with an exposed enum with many options: flying_enemy, ground_enemy, aquatic_enemy. When the type is changed, show the properties of the type picked and hide the rest.

I think you can override _get_property_list in GDScript and return explicitely all export metadata, as an array of this:

# (code copied from a project where I wanted to hide a variable
# by not including PROPERTY_USAGE_EDITOR in "usage", but still have it saved)
return [
	{
		"name": "_data",
		"type": TYPE_ARRAY,
		"usage": PROPERTY_USAGE_STORAGE
	}, etc
]

However I never got “dynamic” properties to work correctly. I know it’s exactly what C++ does (ButtonArray items for example) but in GDScript I may be missing something. The doc is a bit short on it Object — Godot Engine (stable) documentation in English, also check the PROPERTY_USAGE_* enums in the built-in help

Zylann | 2017-01-25 02:29