+1 vote

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?

in Engine by (3,924 points)
edited by

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

1 Answer

+3 votes
Best answer

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.
by (3,924 points)
Welcome to Godot Engine Q&A, where you can ask questions and receive answers from other members of the community.

Please make sure to read Frequently asked questions and How to use this Q&A? before posting your first questions.
Social login is currently unavailable. If you've previously logged in with a Facebook or GitHub account, use the I forgot my password link in the login box to set a password for your account. If you still can't access your account, send an email to [email protected] with your username.