system
1
|
|
|
|
Attention |
Topic was automatically imported from the old Question2Answer platform. |
|
Asked By |
Torajima |
I want to expose or hide variables based on choices in the editor.
Something like this:
export var moving = true
if moving:
export var speed = 200
system
2
|
|
|
|
Reply From: |
ywaby |
use
_get_property_list()
https://forum.godotengine.org/3196/how-add-subcategories-inspector-script-variables-section
example:
tool
extends Spatial
var list_abc = true
var abc = "123"
func _get(property):
if property == "group/subgroup/abc":
return abc
if property == "group/list_abc":
return list_abc
func _set(property, value):
if property == "group/subgroup/abc":
abc = value
if property == "group/list_abc":
list_abc = value
property_list_changed_notify()# update inspect
return true
# call once when node selected
func _get_property_list():
var property_list = []
property_list.append({
"hint": PROPERTY_HINT_NONE,
"usage": PROPERTY_USAGE_DEFAULT,
"name": "group/list_abc",
"type": TYPE_BOOL
})
if list_abc==true:
property_list.append({
"hint": PROPERTY_HINT_NONE,
"usage": PROPERTY_USAGE_DEFAULT,
"name": "group/subgroup/abc",
"type": TYPE_STRING
})
return property_list
What should I use as “type” for an array of enum values? If I’m just exporting normally I would just use:
export (Array, MyEnum) var enum_array
How would I do this with this method?
dopey_kun | 2021-07-19 08:21