Hi,
To my knowledge, there is no way of referencing a variable in the editor.
In the game I’m currently working on, I’m using a generic slider to display some of the player statistics (mostly used for health and armor). To identify my stats, I’m using an enum which looks like this (I’m working in C# but the idea in GDScript would be exactly the same):
public enum StatType
{
HEALTH,
ARMOR,
}
Then, in my player class, I have a dictionary containing the stat instances, with the type as key:
Dictionary<StatType, Stat> statistics;
Which allow me to access those stats based on an enum value that can be exported.
So, in my generic slider class, I can do something like this:
class StatSlider : Control
{
[Export] StatType statType; // -> stat to display
[Export] Player player; // -> player to get stat from
void _Ready()
{
Stat stat = player.statistics[statType] // -> get the stat on ready
// ...
}
}
However, that would cover only one type of object: player statistics. If you want to be able to display anything from any class, I believe you’ll have to use multiple classes for each of your variable types. Sounds like a bore, but I don’t see any other easy way of doing that.
In Unity, you could use ScriptableObjects to create assets storing variables, and then referencing those assets instead of simple values. Basically, they would act as “variable containers” that do nothing special, but with the advantage of being able to be referenced in exported fields.
Anyway, let me know if that helps.