Search Unity

Using UnityEditor.Undo for multiple changes across frames.

Discussion in 'Scripting' started by cjddmut, Mar 1, 2014.

  1. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    120
    I am changing a property of an object once a frame for many frames (until the user confirms or cancels). While there is a cancel, I'd still like an undo but I'm having trouble figuring out how to set this up. The idea would be to create the undo checkpoint before any property change and to confirm when I'm done changing it so it can be added to the undo stack.

    The behavior I want is very similar to if you grab the translate widget in the sceen view to move an object and then undo it after. That movement takes multiple frames, you can't undo in the middle of it but you can undo once it is done.

    Thanks!
    C.J.
     
    Last edited: Mar 1, 2014
  2. cjddmut

    cjddmut

    Joined:
    Nov 19, 2012
    Posts:
    120
    I have appeared to solve my issue. I place the modified objects back in their original state at the beginning of the frame and then use the Undo.RecordObjects before updating their propterties to the latest value.
     
unityunity