How to make a serialized editor only field

Just like the title says, I need a class member that is editable in the inspector, is saved and loaded in the .prefab file when working in the editor, but for a player build that field does not exist in the runtime.

This other Unity answer is the closest thing I could find:

The #ifdef sounds like what I want if it weren’t for the fact that Unity is throwing an error for him that for the player build that is requiring that the serialized field be present … and the “answer” to that question isn’t what I want because by making it non-serialized it will never be saved in the prefab even when working in the editor.

My use case for this is for my localized text objects. I would like to have a string field for localization houses called “Context” which can describe the use case of the string to remove ambiguity when translated.

I know I could store localization data somewhere else, and there’s a lot of ways to do it … but it makes so much sense to keep all of the localization data with the text object itself for a million reasons, we just need persistent, editor only data to do it.

I’d love something that could like like the following if the ideal #ifdef solution is not possible, the field might still be there but at least wouldn’t have any data for a player build:

    public class Translation : MonoBehaviour
    	public string Context;  // explanation of string context (editor only)
    	public string English;  // english text
    	public string German;   // german text

I am seeking a way for SerializeEditorOnly.
use UNITY_EDITOR define on the field will cause a lot of error report.

Only way to do i found

    private string _myField = string.Empty;

Personally i usually group it with #region tag in visual studio to make it more readable

    #region EDITOR-ONLY Serialized
    private string _myField = string.Empty;

Here’s the result
alt text