[SOLVED] Editor script Undo redo explanation please.

:information_source: Attention Topic was automatically imported from the old Question2Answer platform.
:bust_in_silhouette: Asked By SIsilicon

I’m making editor plugins pretty well.
It’s just recently I started to add gui stuff in them. Like a button.
The button in my scenario does something to the scene. Which is great! Except there is no way to undo it, let alone redo it.

Which is why I started looking into theUndoRedo class. The functions and their descriptions aren’t explaining enough for me. Do you know anything else about this class that I need to know when making an editor plugin?

it’s cpp codes but you can get the concept, I think.

volzhs | 2018-06-19 13:23

I understand now. ありがとう!(Thank you!)

SIsilicon | 2018-06-19 14:03

:bust_in_silhouette: Reply From: SIsilicon

In case anyone else wants to know, I now understand how it works.

# First you create an action.
UndoRedo.create_action("action name")

# Then you add your do and undo methods,
UndoRedo.add_do_method(Object that owns method, "do method name")
UndoRedo.add_undo_method(Object that owns method, "undo method name")

# And/or if a property changes in the process you add do and undo properties for those too.
UndoRedo.add_do_property(Object that own property, "property", new value)
UndoRedo.add_undo_property(Object that own property, "property", old value)

# Finally you commit the action.