Auto-populate Editor's class section property

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By cheo

This code works nicely and will let me choose a value in the Editor’s class section property from a drop-down menu:

export(String,"Item1","Item2","Item3") var item_type

Eventually I want to replace “Item”, “Item2”, etc with a variable because I’m importing the data from a dictionary in a JSON file:

var itemjson =  item_data.keys()

that will return a TYPE_ARRAY:

[Item1, Item2, Item3]

I’ve tried several combinations, but none of them work:

export(String,itemsjson) var item_type
export(Array,String) var item_type = itemjson

Any insight on how to accomplish this?

:bust_in_silhouette: Reply From: Calinou

As far as I know, this isn’t supported yet. The items in the export() hint must be a constant expression known at compile-time, which means you have to write the strings manually.

Alright. Thanks for the info

cheo | 2020-12-13 00:10