I have made an EditorScript to help simplify making new levels for a Candy Crush style game.
In it I convert a flat array to a 2D array to form the grid with the different start options for the row and columns position.
All works well if I use it on a new GameObject with the script attached and then make that a prefab, the values for the grid pattern persist, BUT if I try to edit them after the fact the new values for the grid don’t persist and it reverts to the old values after the editor has been restarted.
Am I missing something and is this behaviour to be expected?
Thanks
(See Image for a better overview and the Layout JSON is visible for this debugging)
I noticed something similar today, using an editor script to modify objects while editing a prefab asset. The scripted changes aren’t actually persisted to disk when leaving the prefab edit mode, unless you make at least one manual change before you leave. Not sure if there’s a programmatic workaround… For now I’m just using
EditorUtility.DisplayDialog to remind myself to make a manual change.
I’ve created a sample project and submitted a proper bug report, so maybe this’ll get addressed in a patch…
Can you post a sample of the script? You need to make use of Undo.RecordObject and/or EditorUtility.SetDirty or SerializedObject to make sure your changes are persisted.