NaughtyAttributes
NaughtyAttributes copied to clipboard
[Issue] When using a [Button] that changes a variable it doesn't generate undo/redo commands
This doesn't seem like a bug to me, you need to do:
[Button]
void Change() {
_foo = Random.Range(0, 20);
#if UNITY_EDITOR
UnityEditor.EditorUtility.SetDirty(this);
#endif
}
This applies to any time you change a field outside of play mode, including MenuItem etc.
I also don't think it's a bug. A guy reported it via email, and I wanted to investigate just in case. I was having some issues with prefabs in a prefab instance, and want to see if something regressed
The changes aren't lost btw, I am setting the object dirty in the editor, and the prefab serializes to disk. What the guys meant is that the changes don't generate undo/redo commands.