Get variable name

Hi everyone,
there are a lot of questions (and answers) about getting a variable by name but is there a possibility to get the variable name as a string instead of its value? Basically a BP (or C++ but that I find unlikely) version of C#'s nameof() where a nameof(VARIABLE) is replaced by the actual name at compile time.

Of course it would be no problem to just enter the name by hand but just for convenience sake I wanted to ask.


Hi Schadek,
you can’t, and I don’t think that would be much useful either, how would you use it?

Currently I am using the reflection system to dynamically bind UMG elements to variables of some object. Right now I am typing in the name of each variable by hand to find it on the C++ side which works fine. I was just asking myself of such a funtionality exists because then it would be less work when it comes to variable renaming. Thanks for your answer though. :slight_smile:

This would be super useful for material parameters too - often i’ll use a BP to randomise some values then apply that to a material instance in the BP - typing out 10-30 material parameter names is super tedious when they’re exactly the same as the variable names…

This is exactly what I need to. I have 1920 progress bars on a hud I’d like to reference to, e.g.,

A command like Schadek mentioned in his question would be so useful.

So that’s 3 of us who are unanimous then. Think we’ll need a few more on our side to see it as a built-in function though.

Same this would be a handy node to for UMG, say you have a structure of sever settings you grab the variable name and value and set it to display in UMG.

I really expected this to be a macro function since in C++ precompiler macros you can just do #VARIABLE to get a string literal of the refferenced variable’s identifier. This would also be very useful for debugging.