Download

Having trouble with #if WITH_EDITOR

I’m following the “introduction t C++ programming in UE4” https://docs.unrealengine.com/en-US/Programming/Introduction/index.html documentation and i’m having trouble with getting #if WITH_EDITOR to work. the problem is that PostEditChangeProperty is an editor specific #ifdef which i interpret as the function will be defined when i run it with the editor. but the code won’t compile at all because PostEditChangeProperty is not defined even though it’s within #if WITH_EDITOR so from my understanding it shouldn’t try to compile those lines at all unless it’s with the editor. Am i supposed to include a header file or something? the documentation doesn’t say anything about it

You also need to wrap the declaration of the method in your .h file with #if WITH_EDITOR, otherwise the compiler is looking for a definition which doesn’t exist when compiled for use without the editor.

e.g.



#if WITH_EDITOR
void PostEditChangeProperty(FPropertyChangedEvent& PRopertChangedEvent) override;
#endif