WITH_EDITOR vs WITH_EDITORONLY_DATA - need clarification

Hi,

It’s been few months I didn’t code in C++ with the engine, and I forgot some of the preprocessors stuffs.

Can comeone explain me what are the difference between WITH_EDITOR vs WITH_EDITORONLY_DATA?

From what I can get in the engine source is that “WITH_EDITOR” is stricly related to the build “*Editor” like “DevelopmentEditor” or “DebugEditor”.
and that WITH_EDITORONLY_DATA is linked to the Target platform you want to build against.

Is this correct?

I still don’t understand why we have 2 preprocessor for this. I mean, if you want to build extra stuff for the editor, I understand that you can use the “WITH_EDITOR” one.
What’s the goal of “WITH_EDITORONLY_DATA”. In which case you want to keep fields and function specific to the editor in an non “WITH_EDITOR” version?

Thanks,

5 Likes

Most projects have two modules: MyProject and MyProjectEditor. The MyProject module contains all the gameplay code, data structures, etc. While MyProjectEditor contains any Editor logic you need to extend/alter/etc.

So, let’s say you have an Item class in MyProject, but when this class is shown in the Editor - you want to show some extra fields that contain notes from your designers.

That’s what WITH_EDITORONLY_DATA is for. It lets you add/hide fields without including the entire Editor or redefining the class in your MyProjectEditor module.

ok I think I got it.

It means you can build your “myproject” in shipping mode means WITH_EDITOR is false.
If the target support editor, the WITH_EDITORONLY_DATA will be true and your editor module will be able to load the “myproject” module and access to the WITH_EDITORONLY_DATA fields.

Correct?

Thanks,

2 Likes

I am not sure but from what I’ve seen WITH_EDITOR is used for code while WITH_EDITORONLY_DATA is used for data i.e. class properties etc. There are targets other than Editor that are built with WITH_EDITORONLY_DATA set to true, i.e. some programs like UnrealHeaderTool.

In theory this would allow you to build a project with no editor support that would still be able to load uncooked content.

THanks for the feedback.

In fact WITH_EDITORONLY_DATA is set to true on Windows/Mac/linus platform ie. all the platform that support Editor.

This is why I’m pretty surprise to be able to build Shipping game with “Editor” fields. Not sure if there is a real impact.

It could be great to have a documentation from @Epic on the Preprocessors usage. I can’t see anything in the Wiki / Doc / Comment in source code for this and all I read about this question is just people guessing with their own experience.

All in all, I bet we are not far for the truth

For game code, you can always consider WITH_EDITOR and WITH_EDITOR_ONLYDATA to be the same, like @Robert_Khalikov mentioned, they only differ for special cases like the UnrealHeaderTool

To add some info to this discussion: WITH_EDITORONLY_DATA allows wrapping UPROPERTIEs and UFUNCTIONs, while WITH_EDITOR not.

1 Like