Editor only UFUNCTIONS and UPROPERTIES

Hey guys, so something I’m struggling with at the moment, in relation to my last question (which I’m in the process of trying to answer through this question):

Is there a way to have UPROPERTY() variables that exist for editor use only?

I can simply surround a variable declaration with #if WITH_EDITOR pragmas, but it seems if this variable is a UPROPERTY() the engine looks for it at runtime even in a non-editor build, I assume this is because of something in the generated class. Blueprint editable editor only variables are a nice solution for us to simply make editing information easier without bloating the actual build. Is there any way to actually implement something like this?

Cheers for any thoughts you guys have!

Any news on this? Any replacement for the editoronly keyword in UE3?

The work around (and it is quite disgusting) that I’ve found is this:

When you make a UPROPERTY automatic code is generated in the
Intermediate\Build\Win64\ YourProjectName \Inc\ YourProjectName\ YourBlueprint.gen.cpp

This generated code doesn’t seem to pay attention to the #WITH_EDITOR pragma, so you now have a file that is referencing for build a variable that as far as the actual script is concerned, doesn’t exist. The horrible hack around I found is that you can just go into that .gen.cpp file in …\Inc… and surround your variables with the same #WITH_EDITOR pragmas, this let me build fine, but I have no idea the knock on effects it might have. It also means that every time that .gen.cpp file gets deleted/regenerated, you will have to go back and re-add the #WITH_EDITOR pragmas.

For anybody having this issue, the solution is in that thread:

Data members within UHT parsed types need to be compiled out with #if WITH_EDITORONLY_DATA rather than #if WITH_EDITOR (which you do use for functions).

2 Likes