Guard editor-only data and overrides
The authoring notes and the validation hook exist in the editor and disappear from a cooked build.
WeaponDefinition.hcpp
UCLASS()
class ACTIONGAME_API UWeaponDefinition : public UPrimaryDataAsset
{
GENERATED_BODY()
public:
UPROPERTY(EditDefaultsOnly, Category = "Weapon", meta = (ClampMin = "0.0"))
float DamagePerShot = 25.0f;
#if WITH_EDITORONLY_DATA
UPROPERTY(EditDefaultsOnly, Category = "Authoring")
FString BalanceNotes;
#endif
#if WITH_EDITOR
virtual void PostEditChangeProperty(
FPropertyChangedEvent& PropertyChangedEvent) override;
#endif
};- Why
- A cooked runtime has no editor module. Anything referencing editor types has to compile out, and
WITH_EDITORONLY_DATAalso keeps the field out of the packaged asset. - Costs
- Code inside the guard is not compiled in a Shipping build, so it is never checked by that compile. A packaging break can therefore appear long after the change that caused it.
- Instead
- Use
UPROPERTY(Transient)when a field should exist at runtime but never serialize. Use a separate editor module when the editor-only logic grows past a few functions.

