FuncRef.xml 2.0 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="FuncRef" inherits="Reference" version="3.4">
  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. </return>
  16. <description>
  17. Calls the referenced function previously set in [member function] or [method @GDScript.funcref].
  18. </description>
  19. </method>
  20. <method name="call_funcv">
  21. <return type="Variant">
  22. </return>
  23. <argument index="0" name="arg_array" type="Array">
  24. </argument>
  25. <description>
  26. 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].
  27. </description>
  28. </method>
  29. <method name="is_valid" qualifiers="const">
  30. <return type="bool">
  31. </return>
  32. <description>
  33. Returns whether the object still exists and has the function assigned.
  34. </description>
  35. </method>
  36. <method name="set_instance">
  37. <return type="void">
  38. </return>
  39. <argument index="0" name="instance" type="Object">
  40. </argument>
  41. <description>
  42. 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].
  43. </description>
  44. </method>
  45. </methods>
  46. <members>
  47. <member name="function" type="String" setter="set_function" getter="get_function" default="&quot;&quot;">
  48. The name of the referenced function.
  49. </member>
  50. </members>
  51. <constants>
  52. </constants>
  53. </class>