I have a custom property layout which should (in theory) display a variable number of children based on this property’s value. An adjustable length array, so to speak. So, my CustomizeChildren generates an appropriate number of elements, but I have to push Recompile to update the details panel after changing this value.
I can call any function when it changes using IPropertyHandle::SetOnPropertyValueChanged. So, which function is used to refresh the details view?
I’ve tried NotifyPostChange and some other stuff but none of it works.
I am sure this is possible - after all, TArray does work. But I can’t find its customization code, which would make my life easier. I haven’t tried to make full class details customizations yet, but I will if it’s necessary.
As a side question, where does the “reset to default” button come from? I want to either disable it, or make it reset to my values rather than being completely empty.
I don’t think you can do this with an IPropertyTypeCustomization. It looks like you want to customize one property based on the value of another? If so, you should do that through an IDetailCustomization for the containing class instead.
You’ll get a reference to an IDetailLayoutBuilder, which you can store and later call ForceRefreshDetails on to have the custom layout regenerated.
As for the reset to default, that has a very specific meaning which you shouldn’t try to change - it resets the property to the value specified in the class default object of the given instance’s class (or for a blueprint, to the value from the parent class). So if its behaviour isn’t what you expect, you should probably be putting the default values you want inside the C++ class constructor.
I think in the source above, StructBuilder is probably the IDetailChildrenBuilder& passed in to CustomizeChildren in your derived IPropertyTypeCustomization class.
There is an another solution that I personally consider best and a good practice:
The IPropertyTypeCustomizationUtils type passed to the CustomizeHeader method contains a IPropertyUtilities facility via the GetPropertyUtilities method. This can be passed directly to your OnChange methods that should trigger the refresh as it in turn has the ForceRefresh() method.