Search Unity

Undo.SetSnapshotTarget

Discussion in 'Immediate Mode GUI (IMGUI)' started by CDF, Oct 30, 2014.

  1. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Hi, trying to find an alternative method to Undo.SetSnapshotTarget

    I need to tell undo to start an undo, but not record it. At a later time I need to commit that undo.

    Imagine dragging an object around

    1. On Click, record the object
    2. Drag the object around for any amount of time
    3. On Release, commit the undo

    the Undo.SetSnapshotTarget seemed like the solution, but it's been deprecated. Docs say to use RecordObject, but that is useless because the drag doesn't start until the next frame, meaning the undo system doesn't record any changes.
     
  2. CDF

    CDF

    Joined:
    Sep 14, 2013
    Posts:
    1,311
    Seems like I can just keep calling Undo.RecordObject during the drag, then on mouse up call: Undo.CollapseUndoOperations

    but this just seems very inefficient to me, should I be concerned? What if my object being recorded has lots of nested classes full of lists and references?