I want the Blueprint Compiler to throw an error if a Blueprint is not configured properly by setting up some class properties. To do so, I implement the following method on a class deriving from UUserWidget:
void UUserWidgetCore::ValidateCompiledWidgetTree(const UWidgetTree& BlueprintWidgetTree, class IWidgetCompilerLog& CompileLog) const {
Super::ValidateCompiledWidgetTree(BlueprintWidgetTree, CompileLog);
if (!HasValidBlueprintDependencies()) {
FText OutText = FText::GetEmpty();
FText::FindText(TEXT("EditorLog"), TEXT("Widget_InvalidDependencies"), OutText);
FFormatOrderedArguments Args;
Args.Add(FText::FromString(CompileLog.GetContextClass()->GetName()));
Args.Add(OutText);
FText Message = FText::Format(FTextFormat::FromString("{0} : {1}"), Args);
CompileLog.Error(Message);
}
}
The validation method “HasValidBlueprintDependencies” is a Blueprint Implementable Event.
The problem is, that this method on the blueprint is never called, so the compiler will throw an error even if the method is properly implemented in Blueprints.
What is the correct way to implement this sort of validation?
Edit
Attempting to call a BlueprintImplementableEvent from c++ During “UObject::IsDataValid” also results in the method not being executed. It is simply skipped. Why is this happening?
Edit
When calling the function at a later moment (UUserWidget:Initialize) it works correctly, but this is already way too late to validate the widget.