2020-02-22 13:59:09 +00:00
<?xml version="1.0" encoding="UTF-8" ?>
<class name= "Callable" version= "4.0" >
<brief_description >
2020-03-03 18:21:21 +00:00
An object representing a method in a certain object that can be called.
2020-02-22 13:59:09 +00:00
</brief_description>
<description >
2020-03-03 18:21:21 +00:00
[Callable] is a first class object which can be held in variables and passed to functions. It represents a given method in an [Object], and is typically used for signal callbacks.
[b]Example:[/b]
2020-09-12 15:06:13 +00:00
[codeblocks]
[gdscript]
2020-03-03 18:21:21 +00:00
func print_args(arg1, arg2, arg3 = ""):
prints(arg1, arg2, arg3)
2020-09-12 15:06:13 +00:00
2020-03-03 18:21:21 +00:00
func test():
2021-03-01 14:27:52 +00:00
var callable = Callable(self, "print_args")
callable.call("hello", "world") # Prints "hello world ".
2020-03-03 18:21:21 +00:00
callable.call(Vector2.UP, 42, callable) # Prints "(0, -1) 42 Node(Node.gd)::print_args".
callable.call("invalid") # Invalid call, should have at least 2 arguments.
2020-09-12 15:06:13 +00:00
[/gdscript]
[csharp]
2021-03-01 14:27:52 +00:00
public void PrintArgs(object arg1, object arg2, object arg3 = null)
2020-09-12 15:06:13 +00:00
{
GD.PrintS(arg1, arg2, arg3);
}
public void Test()
{
2021-03-01 14:27:52 +00:00
Callable callable = new Callable(this, nameof(PrintArgs));
callable.Call("hello", "world"); // Prints "hello world null".
callable.Call(Vector2.Up, 42, callable); // Prints "(0, -1) 42 Node(Node.cs)::PrintArgs".
2020-09-12 15:06:13 +00:00
callable.Call("invalid"); // Invalid call, should have at least 2 arguments.
}
[/csharp]
[/codeblocks]
2020-02-22 13:59:09 +00:00
</description>
<tutorials >
</tutorials>
<methods >
2020-11-10 13:16:20 +00:00
<method name= "Callable" qualifiers= "constructor" >
2021-07-30 13:28:05 +00:00
<return type= "Callable" />
2020-11-09 16:46:03 +00:00
<description >
Constructs a null [Callable] with no object nor method bound.
</description>
</method>
2020-11-10 13:16:20 +00:00
<method name= "Callable" qualifiers= "constructor" >
2021-07-30 13:28:05 +00:00
<return type= "Callable" />
<argument index= "0" name= "from" type= "Callable" />
2020-11-09 16:46:03 +00:00
<description >
Constructs a [Callable] as a copy of the given [Callable].
</description>
</method>
2020-11-10 13:16:20 +00:00
<method name= "Callable" qualifiers= "constructor" >
2021-07-30 13:28:05 +00:00
<return type= "Callable" />
<argument index= "0" name= "object" type= "Object" />
<argument index= "1" name= "method" type= "StringName" />
2020-02-22 13:59:09 +00:00
<description >
2020-11-09 16:46:03 +00:00
Creates a new [Callable] for the method called [code]method[/code] in the specified [code]object[/code].
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "bind" qualifiers= "vararg const" >
2021-07-30 13:28:05 +00:00
<return type= "Callable" />
2020-10-12 08:57:54 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns a copy of this [Callable] with the arguments bound. Bound arguments are passed after the arguments supplied by [method call].
2020-10-12 08:57:54 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "call" qualifiers= "vararg const" >
2021-07-30 13:28:05 +00:00
<return type= "Variant" />
2020-02-22 13:59:09 +00:00
<description >
2020-03-03 18:21:21 +00:00
Calls the method represented by this [Callable]. Arguments can be passed and should match the method's signature.
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "call_deferred" qualifiers= "vararg const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2020-02-22 13:59:09 +00:00
<description >
2020-03-03 18:21:21 +00:00
Calls the method represented by this [Callable] in deferred mode, i.e. during the idle frame. Arguments can be passed and should match the method's signature.
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "get_method" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "StringName" />
2020-02-22 13:59:09 +00:00
<description >
2020-03-03 18:21:21 +00:00
Returns the name of the method represented by this [Callable].
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "get_object" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Object" />
2020-02-22 13:59:09 +00:00
<description >
2020-03-03 18:21:21 +00:00
Returns the object on which this [Callable] is called.
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "get_object_id" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2020-02-22 13:59:09 +00:00
<description >
2020-03-03 18:21:21 +00:00
Returns the ID of this [Callable]'s object (see [method Object.get_instance_id]).
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "hash" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "int" />
2020-02-22 13:59:09 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns the hash value of this [Callable]'s object.
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "is_custom" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2020-02-22 13:59:09 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns [code]true[/code] if this [Callable] is a custom callable whose behavior differs based on implementation details. Custom callables are used in the engine for various reasons. If [code]true[/code], you can't use [method get_method].
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "is_null" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2020-02-22 13:59:09 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns [code]true[/code] if this [Callable] has no target to call the method on.
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "is_standard" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2020-02-22 13:59:09 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns [code]true[/code] if this [Callable] is a standard callable, referencing an object and a method using a [StringName].
2020-02-22 13:59:09 +00:00
</description>
</method>
2021-06-30 14:36:46 +00:00
<method name= "is_valid" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
2021-06-30 14:36:46 +00:00
<description >
Returns [code]true[/code] if the object exists and has a valid function assigned, or is a custom callable.
</description>
</method>
2021-09-17 15:22:48 +00:00
<method name= "operator !=" qualifiers= "operator" >
<return type= "bool" />
<description >
</description>
</method>
2020-11-10 13:16:20 +00:00
<method name= "operator !=" qualifiers= "operator" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "right" type= "Callable" />
2020-11-10 13:16:20 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns [code]true[/code] if both [Callable]s invoke different targets.
2020-11-10 13:16:20 +00:00
</description>
</method>
2021-09-17 15:22:48 +00:00
<method name= "operator ==" qualifiers= "operator" >
<return type= "bool" />
<description >
</description>
</method>
2020-11-10 13:16:20 +00:00
<method name= "operator ==" qualifiers= "operator" >
2021-07-30 13:28:05 +00:00
<return type= "bool" />
<argument index= "0" name= "right" type= "Callable" />
2020-11-10 13:16:20 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns [code]true[/code] if both [Callable]s invoke the same custom target.
2020-11-10 13:16:20 +00:00
</description>
</method>
2021-05-03 21:00:44 +00:00
<method name= "rpc" qualifiers= "vararg const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
2021-05-03 21:00:44 +00:00
<description >
Perform an RPC (Remote Procedure Call). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling it on unsupported functions will result in an error.
</description>
</method>
<method name= "rpc_id" qualifiers= "vararg const" >
2021-07-30 13:28:05 +00:00
<return type= "void" />
<argument index= "0" name= "peer_id" type= "int" />
2021-05-03 21:00:44 +00:00
<description >
Perform an RPC (Remote Procedure Call) on a specific peer ID (see multiplayer documentation for reference). This is used for multiplayer and is normally not available unless the function being called has been marked as [i]RPC[/i]. Calling it on unsupported functions will result in an error.
</description>
</method>
2021-03-18 13:44:42 +00:00
<method name= "unbind" qualifiers= "const" >
2021-07-30 13:28:05 +00:00
<return type= "Callable" />
<argument index= "0" name= "argcount" type= "int" />
2020-10-12 08:57:54 +00:00
<description >
2020-09-12 15:30:08 +00:00
Returns a copy of this [Callable] with the arguments unbound. Calling the returned [Callable] will call the method without the extra arguments that are supplied in the [Callable] on which you are calling this method.
2020-10-12 08:57:54 +00:00
</description>
</method>
2020-02-22 13:59:09 +00:00
</methods>
<constants >
</constants>
</class>