I’m trying to execute some code in editor after a blueprint is compiled. I would use constructor, but I need the details panel values for my UProperties.
I was hoping PostInitProperties would allow me to achieve this, but it seems that it still does not use the details panel values (at least in editor).
The only thing that kind of works is PostEditChangeProperty, but that isn’t called after compilation, which is a bit frustrating
you can override ```/**
* Called after the Blueprint compiler has finished generating the Class Default Object (CDO) for a class. This can only happen in the editor.
* This is called when the CDO and its associated class structure have been fully generated and populated, and allows the assignment of cached/derived data,
* eg) caching the name/count of properties of a certain type, or inspecting the properties on the class and using their meta-data and CDO default values to derive game data.
*/
virtual void PostCDOCompiled(const FPostCDOCompiledContext& Context)
{
}``` or COREUOBJECT_API virtual void PreSaveRoot(FObjectPreSaveRootContext ObjectSaveContext);
and COREUOBJECT_API virtual void PostSaveRoot(FObjectPostSaveRootContext ObjectSaveContext);
as these are when you save the BP.
I actually realized compilation wouldn’t end up really helping me anyways, because I’m calling this from a DataAsset anyway, and there is no compile button in a data asset in editor (which I completely forgot).
So for what I’m trying to do, I’ll probably have to subscribe to a delegate within the AssetRegistry
I think PostEditChangeProperty is right way for details panel. If you want to catch step after value changes are done you need an additional check within this method. Here is an example:
#if WITH_EDITOR
void AMyActor::PostEditChangeProperty(FPropertyChangedEvent& PropertyChangedEvent)
{
Super::PostEditChangeProperty(PropertyChangedEvent);
if (!PropertyChangedEvent.Property)return;
const FName ChangedPropName = PropertyChangedEvent.Property->GetFName();
if (ChangedPropName == GET_MEMBER_NAME_CHECKED(ATerrainActor, MyProperty) )
{
if (PropertyChangedEvent.ChangeType != EPropertyChangeType::Interactive)
{
/* == Interactive means:
still editing the value*/
/* != Interactive means:
Slider released
Manually entered number/string + Enter
Checkbox check/uncheck done
ComboBox selection done
Final value came.
*/
CallFunction(arg1,arg2...);
}
}
}
#endif