hotari
1
Godot Version
v4.3.stable.official [77dcf97d8]
Question
When I bind a value to Array.append
and pass it as a Callable
arg to UndoRedo.add_do_method
, the array seems unchanged.
Cannot I use UndoRedo
to add or remove elements of arrays?
Reproduction
_undo_redo.create_action('Add 5')
_undo_redo.add_do_method(_array.append.bind(5))
_undo_redo.add_undo_method(_array.erase.bind(5))
_undo_redo.commit_action()
This results _array -> []
.
Thank you!
hotari
2
In godot source:
void UndoRedo::add_do_method(const Callable &p_callable) {
ERR_FAIL_COND(!p_callable.is_valid());
ERR_FAIL_COND(action_level <= 0);
ERR_FAIL_COND((current_action + 1) >= actions.size());
ObjectID object_id = p_callable.get_object_id();
Object *object = ObjectDB::get_instance(object_id);
ERR_FAIL_COND(object_id.is_valid() && object == nullptr);
Array
is NOT Object
so Array
has no object ID:
get_object_id() -> 0
get_object() -> null
UndoRedo
does not call Array
methods 
system
Closed
3
This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.