mirror of
https://github.com/godotengine/godot.git
synced 2024-11-24 13:12:42 +00:00
Merge pull request #44918 from Chaosus/vs_assign_default_value
Auto-assign default value for variable in visual script on type changing
This commit is contained in:
commit
efdca23f87
@ -227,6 +227,19 @@ protected:
|
||||
undo_redo->create_action(TTR("Set Variable Type"));
|
||||
undo_redo->add_do_method(script.ptr(), "set_variable_info", var, dc);
|
||||
undo_redo->add_undo_method(script.ptr(), "set_variable_info", var, d);
|
||||
|
||||
// Setting the default value.
|
||||
Variant::Type type = (Variant::Type)(int)p_value;
|
||||
if (type != Variant::NIL) {
|
||||
Variant default_value;
|
||||
Callable::CallError ce;
|
||||
Variant::construct(type, default_value, nullptr, 0, ce);
|
||||
if (ce.error == Callable::CallError::CALL_OK) {
|
||||
undo_redo->add_do_method(script.ptr(), "set_variable_default_value", var, default_value);
|
||||
undo_redo->add_undo_method(script.ptr(), "set_variable_default_value", var, dc["value"]);
|
||||
}
|
||||
}
|
||||
|
||||
undo_redo->add_do_method(this, "_var_changed");
|
||||
undo_redo->add_undo_method(this, "_var_changed");
|
||||
undo_redo->commit_action();
|
||||
|
Loading…
Reference in New Issue
Block a user