dynamic export type #7016
Replies: 4 comments 1 reply
-
You can achieve this with |
Beta Was this translation helpful? Give feedback.
-
See godotengine/godot#75778. If/when |
Beta Was this translation helpful? Give feedback.
-
I came across this issue myself and wrote the resource class below to allow me to have an exported var that has a type not specified in code, but in the editor. It's not perfect or the cleanest in the editor, but it works for my case. I just used an Array and limited it to 1 element since Arrays support any type of Variant. I also make sure that the variant matches the specified type because I want to be sure the type of the value stays consistent for each resource instance.
|
Beta Was this translation helpful? Give feedback.
-
I think that we should be able to export Variants. eg @export var foo: Variant It could use the same interface in the inspector as untyped Array values or Dictionary keys/values. Currently this can be worked around by just exporting an array and accessing the first value as mentioned above but that feels a bit hacky when there is already a way to set Variant data in the inspector. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Is there a way to dynamically change the type of @export var,
Ex:
I have an enum:
There is a subcategory:
my idea is that you can then select categories and so on:
because dynamic type conversion is not supported, sub_category can only be defined as int.
If something like this:
This will then display the name I want to choose in the form of enum in the inspector
Beta Was this translation helpful? Give feedback.
All reactions