Open Novakasa opened 4 years ago
I looked a bit into this and I've not found the offending code, but I found a hint.
Turns out that classes that can be casted to Resource
can call undo methods:
So switching your ActionRef
to extend Resource
like the following should work:
tool
class_name ActionRef
extends Resource
func output(message):
print(message)
You could use this as a workaround in the meantime.
This UndoRedo
class may need to be retouched -- there are quite a few casts to Resource
in there that don't show any warnings at all, but should inform the user what's happening underneath.
I'm also not sure why UndoRedo
would specifically need Resource
references as none of these references seem to get serialized, but perhaps it was left that way so that when users build tools with EditorPlugin
or GraphEdit
for example, they could save the sessions on those tools rather easily along with their UndoRedo
history, but the serialization of UndoRedo
's history was never implemented.
Godot version: v3.2.2.stable.official
OS/device including version: Windows 10 x64, two different systems tested
Issue description: After adding a undo method for a
UndoRedo
action, it will only be called on undoing the action if the object is a builtin type, or extendsEditorPlugin
I'm wondering if that is intended behaviour, in that case we should probably add something to the documentation.
Example:
undo_test.gd
:action_plugin.gd
:action_ref.gd
:Then, when executing the action (press F12), both output methods are called. When undoing the action, only the undo method for the instance which extends
EditorPlugin
is called.Steps to reproduce:
UndoRedo
actionobject
that is neither builtin norextends EditorPlugin
undo.add_undo_method(object, method, params)
UndoRedo
actionobject
instance will not be calledMinimal reproduction project: https://github.com/lolligerjoj/undo_test.git