Hello.
I am working on a system which requires variable number of properties per component. Due to this requirement we cannot use a fixed UObject/UComponent derived class. One way to solve this problem would be to use arrays, but that would not be a very clean solution and would add some extra effort to make it work with Blueprint system and make it look nice.
Right now, when we load our resource, we parse it, create component, extract properties / fields from our resource, then create custom UClass object and insert our fields as properties into this new UClass object. After that we replace component’s original UClass with our own.
This seems to work, more or less, and I have some follow up questions:
- Class field is a private member of UObjectBase, we do some hacking in order to replace it with our own. Any other approach?
- We insert our custom UProperty objects into UClass’s PropertyLink and Children lists. Is this correct approach?
- Dealing with UProperty offsets. The issue is, as I understand, that property’s offset is an offset from “this”. If that’s the case, why is offset a signed int? This design also forces us to store all propety values inside our component. Right now we just use a fixed size char buffer (say 64k) at the end of component and make sure our property offsets point to that buffer - this seems to work, but it’s a bit of a pain and a serious limitation. One solution would be to request a larger memory block and store properties at the end of that memory block, past the component layout, but that seems like a dangerous approach especially if users start using same approach to store meta data as well. Another solution would be to patch offset to be 64 bit int - in this case property would be able to be outside the component as pointer jump would be valid (with current 32 bit offsets, that’s not the case). Any recommendations? We would like to keep this Plugin side, with no UE core changes (unless this would be a valid pull request change).
- How to force editor to update details panel for active actor / component? When we patch properties, the details panel is not updated automatically. You have to click on an actor in order for it to be updated.
- Would there be any side effects with this approach (patching the class object per instance) - for example during serialization? We’ve avoided this problem by repatching the class information back, serializing and then restoring new object. But I am wondering if that’s unnecessary.
I very much appreciate any responses, thanks.