variable number of component/actor properties

Simple question. Can I have a variable number of exposed properties on a C++ component or actor?

I’m asking this from the prospective of a plugin writer. What I’m trying to do is create a component or actor that can load external data and create the correct type and number of exposed manipulable properties (UPROPERTY-like) to interact with the loaded data. Is this remotely possible, even if not through UPROPERTY's?

If feels like you’d need to recompile the component or actor every time the number of properties changes. That’s how adding variables/properties in the Blueprint editor seems to require. If so, can I require and use that compilation step to add my generated properties in C++?

Thanks!

I don’t really understand your use case. You can’t change the structure of a header file without recompiling it.

If you just want there to be a variable number of things in a class, the usual method is to make a USTRUCT, add properties to that, and then have a TArray of that UStruct. You could use that to implement anything you want, look at the code base for UStruct examples

Basically, my component loads procedurally generated geometry from a custom library. The custom library also exposes a set of parameters, of different types (float, int, floatvec3, etc.), that can be changed to generate different geometries.

I currently do use a property of an array of UStructs to expose this to Blueprint where I have to manually expose each custom parameter with an explicit public variable of the correct type so the user can change the values in the editor Details panel. Of course, when I load a different data set, with different parameters, my public variables no longer match the custom parameters.

I’m wondering if I can automate this process somewhat. I know I’d have to recompile my actor/component if I’d like a UPROPERTY for each one of my custom parameter. I guess my question is, can I do this? Can I call into UE4’s runtime compiler to recompile a new version of my component/actor?

Not easily. You could consider making these changes directly to a blueprint instead of there being a native file in the middle, that would take some custom work but would probably do what you want. We don’t support something like this out of the box, there’s no way to “export to blueprint” really.

I thought so. I just wanted to check there wasn’t anything obvious I missed. But thanks!