Is it possible to have conditionally exported variables?
what I mean is something like this:
@export var is_moving_platform:bool = false
@exportif(is_moving_platform=true) var point1:Vectory3 = Vector3.ZERO
@exportif(is_moving_platform=true) var point2:Vectory3 = Vector3.ONE
So in the editor, the variables point1 and point2 would only appear if is_moving_platform is checked.
I believe this should be possible as I can see some of the settings for built-in types have something like that.
for example Area3D’s Gravity, you can check point to have some more options appear
OK after reading the wiki I can honestly say I do not fully comprehend it, however I was able to understand enough to make it work for what I wanted.
In case this is useful for others, this is what I did:
# @tool is absolutely needed
@tool extends Node3D
@export_category("Tile")
# This variable has to be exported
@export var is_moving_platform:bool = false:
set(value):
if value == is_moving_platform : return
is_moving_platform = value
notify_property_list_changed()
# These variables are going to be shown when is_moving_platform is checked.
var moving_speed:float = 5.0
var moving_points:Array[Node3D]
func _get_property_list():
if Engine.is_editor_hint():
var ret =[]
if is_moving_platform:
# This is how you add a normal variable, like String (TYPE_STRING), int (TYPE_INT)...etc
ret.append({
"name": &"moving_speed",
"type": TYPE_FLOAT,
"usage": PROPERTY_USAGE_DEFAULT,
})
# This is how you add an Array, to define a type it seems that "24/34:Class_Name" is needed in the hint_string, or you will end up with null
ret.append({
"name": &"moving_points",
"type": TYPE_ARRAY,
"hint": PROPERTY_HINT_TYPE_STRING,
"hint_string": "24/34:Node3D",
"usage": PROPERTY_USAGE_EDITOR | PROPERTY_USAGE_STORAGE | PROPERTY_USAGE_SCRIPT_VARIABLE
})
return ret
Thank you @dbat for the answer, you can feel free to close this Topic.