I am just creating my custom class in C++, which I intent to use in BP. I am having difficulties in exposing variables in BluePrint, that you might refer to as static variables in C++. In the Blueprint editor, it is called “Class Variable”.
I know that there are a lot of Property-Specifiers, that enable an “Object Variable” to be exposed in the BP editor. Which is what I have no problem with. However, when I intent to create a class variable I am out of ideas :(.
How do you create and expose variables, that can be queried by the class it self? Again, I know how to create the “blue” variables in C++, but I cant find any information on the purple ones.
Does anybody know how to do that and can post an example please?
So here is a node I want to get a variable from, how do I expose it in C++?
Class varable is UClass* as this is class identifier in reflection system, it’s also UObject on it self. When you start engine each class will have UClass created for them use to identify them. There also TSubclassOf which you use like this:
This is same as UClass* but it a special template which limits selection of classes in editor to specific subclass so this above will show only actor classes in editor.
In C++ you can get UClass* of any class in C++ by using StaticClass() static function like this AMyActor::StaticClass() and from object using GetClass() function.
thank you for your response and thanks for the information. I see, my question is a bit misleading. My problem is, that I don’t know how to get “static” (or class-variables (“the purple ones”)) properties in the blueprint editor:
There is a lot of documentation on the usual “Object variables” (“the blue nodes”) and how to expose them via macros for BP. But since I just want to get some static information without creating an object, I seem to have to create these “Class variables” and get them from a class node itself. However, I cant find any documentation on how doing so.
You can’t reflection system dont support static varbales, only static functions which is something you could use to access static varbale.
If you want to access something like actor meta data (like price of item, stat points) make them regular variables, set values as defaults and access them via class defaults which is nowpossible since not that long ago.
Also as i sad UClass is also UObject, so in blueprint terminology that you use it is also “Object Reference” but reference of a class identifier, in order for varable to show there it would need to be varable of UClass