Download

Generate Blueprint errors to validate data, is it possible?

Hi, I noticed this code in the BlueprintEditor::Compile, and wondering if part of this can be used to log some errors from UObjects



	FCompilerResultsLog LogResults;
		LogResults.bLogDetailedResults = GetDefault<UBlueprintEditorSettings>()->bShowDetailedCompileResults;
		LogResults.EventDisplayThresholdMs = GetDefault<UBlueprintEditorSettings>()->CompileEventDisplayThresholdMs;
		FKismetEditorUtilities::CompileBlueprint(BlueprintObj, false, false, bSaveIntermediateBuildProducts, &LogResults);


Assume I want to validate data and log possible errors to the user using this method, I generate errors and log them to the user. He will need to change the values in order to get a clean blueprint compilation.

Is this possible at all? Is there any other method you recommend me to validate this information?
Regards

You could add a CheckForErrorsmethod to your actors, it will give you try to log any errors in the map check dialog so the user will then be able to act accordingly. In the engine source there a lot of exampleson how to use it, it’s fairly simple and super useful.

That sounds great, I hope this works for UObjects, looking at the code. Thanks!

[edit] correct me if I am wrong, this only seems to work for AActors, won’t work for the UObjects?

Alright, I managed to generate the errors for the UObjects, regardless there is no function to override (CheckForErrors). The way errors get generated is in the default constructor, would this be a proper and safe way to proceed?
I managed to get the errors loged in the Output Log, but it would also help to generate a Compile error in the blueprint, until all the messages are fixed, any recommendation?

I have changed the Errors logs to PostEditChangeProperty and that seems to be the solution.

Lastly, I will only need a way to expose the error in the editor (i.e. generate blueprint compile error).

How would you think about exposing the errors? You could also drive all error checking form an actor in your map to be able to make use of check method.