Language

How to save a Prefab modified by an Editor script?

I've tried Undo.RecordObject, EditorUtility.SetDirty, PrefabUtility.RecordPrefabInstancePropertyModifications, and AssetDatabase.SaveAssets but I can't get scripted changes to a prefab to stick in 2018.3.1.

5 - Exit the prefab, then select the same prefab again and click Open Prefab again. FieldOne says "hello". FieldTwo is now blank / reverted to its previous value (!!)

!! - Oddly, fieldTwo KEEPS its new value if I skip step 3; that is, if I type into fieldOne then programmatically change fieldTwo's value without navigating away from the prefab in the inspector. Made this bug hard to track down...