FuncRef.xml 2.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="FuncRef" inherits="Reference" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../class.xsd">
  3. <brief_description>
  4. Reference to a function in an object.
  5. </brief_description>
  6. <description>
  7. In GDScript, functions are not [i]first-class objects[/i]. This means it is impossible to store them directly as variables, return them from another function, or pass them as arguments.
  8. However, by creating a [FuncRef] using the [method @GDScript.funcref] function, a reference to a function in a given object can be created, passed around and called.
  9. </description>
  10. <tutorials>
  11. </tutorials>
  12. <methods>
  13. <method name="call_func" qualifiers="vararg">
  14. <return type="Variant" />
  15. <description>
  16. Calls the referenced function previously set in [member function] or [method @GDScript.funcref].
  17. </description>
  18. </method>
  19. <method name="call_funcv">
  20. <return type="Variant" />
  21. <argument index="0" name="arg_array" type="Array" />
  22. <description>
  23. Calls the referenced function previously set in [member function] or [method @GDScript.funcref]. Contrarily to [method call_func], this method does not support a variable number of arguments but expects all parameters to be passed via a single [Array].
  24. </description>
  25. </method>
  26. <method name="is_valid" qualifiers="const">
  27. <return type="bool" />
  28. <description>
  29. Returns whether the object still exists and has the function assigned.
  30. </description>
  31. </method>
  32. <method name="set_instance">
  33. <return type="void" />
  34. <argument index="0" name="instance" type="Object" />
  35. <description>
  36. The object containing the referenced function. This object must be of a type actually inheriting from [Object], not a built-in type such as [int], [Vector2] or [Dictionary].
  37. </description>
  38. </method>
  39. </methods>
  40. <members>
  41. <member name="function" type="String" setter="set_function" getter="get_function" default="&quot;&quot;">
  42. The name of the referenced function.
  43. </member>
  44. </members>
  45. <constants>
  46. </constants>
  47. </class>