Best practices for editor-only data/logic in mixed system

Hi there!

We have a plugin that is composed of two modules, a runtime module (MyModule) and an editor module (MyModuleEditor) configured with “Type”: “Editor”.

MyModuleEditor implements editor functionality that leverages functionality in MyModule so we naturally have a MyModuleEditor -> MyModule dependency.

This system is heavily data driven, and as such inside of MyModule we have defined a UDataAsset that has important stuff that is used at runtime (let’s call this UMyModuleData).

We want the editor functionality to also be data driven, and ideally we would be defining a UDataAsset type that is editor-only data and contains information consumed by MyModuleEditor to implement its logic (let’s say UMyModuleEditorData).

The problem is - how can we link UMyModuleEditorData to a UMyModuleData?

Ideally, UMyModuleEditorData would be defined in the MyModuleEditor and referenced by UMyModuleData, but if that’s the case then we create a MyModule -> MyModuleEditor dependency which is not allowed as a cyclical module dependency.

We could get rid of UMyModuleEditorData and just put editor data inside of UMyModuleData guarded with WITH_EDITORONLY_DATA, however, that pollutes the runtime module MyModule with a bunch of types and logic that would be better contained inside of an editor-only module like MyModuleEditor.

Do you have any recommendation?

Are there UE systems that have solved similar problems in some way?

Hello!

The recommendation would be to use WITH_EDITORONLY_DATA at the runtime class level to isolate the editor part of the data. It could be an anonymous pointer as we do with UClass::ClassGeneratedBy.

There might also be some opportunities with details customizations if the editor structure is meant to “simplify” the edition of the runtime version. https://dev.epicgames.com/documentation/en\-us/unreal\-engine/details\-panel\-customizations\-in\-unreal\-engine

Martin