How to handle reflection from editor to runtime.

I am making my own node editor based on a simple framework. One thing I have not been able to figure out is how to get reflection working properly.

What would be the (generalized) way of going about typing a string into an (node) editor window and then pulling data from some class at runtime?

For example. If in the editor I type $health, I want to get the Player.Health.currentValue at runtime. Do I need to store the player class somewhere? How do I get to the correct object of the class?

I’ve been looking around tutorials and manuals, but only find general explanations of reflections, which I understand. What I dont know is how to deal with writing something in the editor and then during runtime access the relevant variable.

Maybe using statics? The idea is to stay away from that as well as from singletons.

What platform are you aiming to build for? If you’re exporting to Web or another AoT (ahead of time compilation) platform, this can be a struggle. If you’re building a standalone build though using reflection it’s possible (and easy).

GetType().GetField("health").SetValue(this, 10);