A simple step-by-step guide on how to add an assert-like blueprint node to Unreal Engine.
https://dev.epicgames.com/community/learning/tutorials/1lOj/unreal-engine-implementing-blueprint-asserts-in-c
Hi, I was also searching for this functionality and found this.
I want to share some nodes I made thanks to this tutorial.
#include "Blueprint/BlueprintExceptionInfo.h"
/* Triggers a Blueprint Breakpoint, causing the game to pause execution at the current node */
UFUNCTION(BlueprintCallable, Category = "Development", meta = (DevelopmentOnly, DefaultToSelf = "ActiveObject", HidePin = "ActiveObject"))
static void InvokeBreakpoint(const UObject* ActiveObject)
{
FBlueprintExceptionInfo ExceptionInfo(
EBlueprintExceptionType::Breakpoint,
NSLOCTEXT("UMyBlueprintFunctionLibrary1", "Breakpoint Message", "Invoked Breakpoint"));
FFrame* StackFrame = FBlueprintContextTracker::Get().GetCurrentScriptStackWritable().Last();
FBlueprintCoreDelegates::ThrowScriptException(ActiveObject, *StackFrame, ExceptionInfo);
}
/* Triggers a Blueprint Runtime Error, similar to the well-known "Accessed None" error.
* Execution continues normally, but an error message is logged in the MessageLog after the game ends. */
UFUNCTION(BlueprintCallable, Category = "Development", meta = (DevelopmentOnly, DefaultToSelf = "ActiveObject", HidePin = "ActiveObject"))
static void InvokeRuntimeError(
const UObject* ActiveObject,
const FString Message = "Invoked Runtime Error")
{
FFrame* StackFrame = FBlueprintContextTracker::Get().GetCurrentScriptStackWritable().Last();
FBlueprintExceptionInfo ExceptionInfo(
EBlueprintExceptionType::AccessViolation,
FText::FromString(Message));
FBlueprintCoreDelegates::ThrowScriptException(
ActiveObject,
*StackFrame,
ExceptionInfo);
}
Result:
Invoke Runtime Error: