Fuwari
69 words
1 minutes
"Call In Editor" doesn't get ran - Script Guard Usage Guide
2024-11-24

Problem#

Sometimes, when you have a “Call In Editor” function/event, and you call it in editor, some of it’s cpp code doesn’t get run.
For example:

//A delegate you made
DECLARE_DYNAMIC_DELEGATE_OneParam(FDelegateFoo,int,Result);
//Initialize callback
FDelegateFoo Callback=Something;

//Use callback
UE_LOG(LogTemp, Warning, TEXT("Debug!"));
Callback.ExecuteIfBound(123);

The text “Debug!” is printed, but the callback isn’t called.

Cause#

For some reason, ue5 doesn’t run certain functions while in editor mode.

Solution#

Adding a ScriptGuard will make sure the functions get ran:

FEditorScriptExecutionGuard ScriptGuard;
Callback.ExecuteIfBound(123);//Is ran!
"Call In Editor" doesn't get ran - Script Guard Usage Guide
https://fuwari.vercel.app/posts/ue5/scriptguardusage/
Author
Lorem Ipsum
Published at
2024-11-24