Search Unity

Undo support for editor windows

Discussion in 'Scripting' started by zoran404, Jul 26, 2017.

  1. zoran404

    zoran404

    Joined:
    Jan 11, 2015
    Posts:
    520
    I'm creating an editor window for my scriptable objects and I want to be able to undo the changes I make to it.

    Currently I only call EditorUtility.SetDirty so that the changes get saved.
    I tried also calling Undo.RecordObject, but that doesn't really do anything.

    Is it possible to do using Unity's Undo system or will I need to handle Ctrl+Z myself?
     
  2. RoMax92

    RoMax92

    Joined:
    May 29, 2017
    Posts:
    135
  3. zoran404

    zoran404

    Joined:
    Jan 11, 2015
    Posts:
    520
    Yeah, as I said I already tried using Undo, but it turned out I was using it wrong.

    I was calling it after making a change, instead of before doing it.
    And I wasn't repainting the window when an undo was performed (I just assumed the repaint will happen), so I couldn't see it happen anyway.