I was wondering, is there any way to determine at compile time if we’re running in the UE4 editor, or in a packaged game? Is there some sort of compile-time constant defined by UE4’s build system like UE4_EDITOR so that I can write
Difference between WITH_EDITOR and WITH_EDITORONLY_DATA is this:
WITH_EDITOR: used to exclude complete functions (declaration and definition) in packaged games. Mostly used for EDITOR functions which cause compile errors in packaged game where you dont have editor module
WITH_EDITORONLY_DATA: used to mark things inside the scope and inside the function (you cant exclude complete functions, but you can exclude different things inside the function)
for example:
.h
#if WITH_EDITOR
void EditorFunction();
#endif
.cpp
#if WITH_EDITOR
void Class::EditorFunction()
{
// do something
}
#endif
2.
void Class::BeginPlay()
{
int32 i = 0;
#if WITH_EDITORONLY_DATA
i = 1; // be one while we using editor
#endif
}