mirror of
https://github.com/godotengine/godot.git
synced 2026-01-03 18:11:19 +03:00
Allow binding Callable arguments from an array
Restores 3.x functionality that was removed in the Signal/Callable refactor of 4.0. Fixes #64668. Implements https://github.com/godotengine/godot-proposals/issues/6034 Usage: ```GDScript callable.bindv([arg1,arg2,arg3]) ```
This commit is contained in:
@@ -102,6 +102,20 @@ Callable Callable::bindp(const Variant **p_arguments, int p_argcount) const {
|
||||
}
|
||||
return Callable(memnew(CallableCustomBind(*this, args)));
|
||||
}
|
||||
|
||||
Callable Callable::bindv(const Array &p_arguments) {
|
||||
if (p_arguments.is_empty()) {
|
||||
return *this; // No point in creating a new callable if nothing is bound.
|
||||
}
|
||||
|
||||
Vector<Variant> args;
|
||||
args.resize(p_arguments.size());
|
||||
for (int i = 0; i < p_arguments.size(); i++) {
|
||||
args.write[i] = p_arguments[i];
|
||||
}
|
||||
return Callable(memnew(CallableCustomBind(*this, args)));
|
||||
}
|
||||
|
||||
Callable Callable::unbind(int p_argcount) const {
|
||||
return Callable(memnew(CallableCustomUnbind(*this, p_argcount)));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user