Creating a UProperty
I want to have a UProperty as a Member of my Class. However I do not mean having a c++ variable, that is reflected as a UProperty like this:
but having the member itsself be the UProperty like this
or as a pointer of course. I want to use it to store a varibale of dynamic type without templating the whole class. Is this possible? If so, how do I create a UNumericProperty for example? I have tried
but I dont really understand where UProperty belongs in this context (if it as treadet as a UObject or what else)
It is, I think, technically possible to reference UProperty of an existing class in another class, but I assume a reference to a UProperty is not reliable as it will change if the class is modified either from compiling c++ code or compiling blueprint.
The safer way to do it is to save the UClass where the property is in along with the property's Name. Both are guaranteed to be serialized properly and getting the UProperty instance is trivial if you have those two.
Creating UProperty on the fly just like what you plan to do, however, is not possible. UProperty is a special object that is stored as a linked list in a class, it is part of the reflection system that works like a map to get a certain value from a a certain offset in an object's byte data. UProperty that is created outside of the reflection system will not work properly and will be a dangerous map to a value in an object, and I just don't see it as implementable without changing the engine code.
Follow this question
Once you sign in you will be able to subscribe for any updates here