Object.xml 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438
  1. <?xml version="1.0" encoding="UTF-8" ?>
  2. <class name="Object" category="Core" version="3.1">
  3. <brief_description>
  4. Base class for all non built-in types.
  5. </brief_description>
  6. <description>
  7. Base class for all non built-in types. Everything which is not a built-in type starts the inheritance chain from this class.
  8. Objects can be constructed from scripting languages, using [code]Object.new()[/code] in GDScript, [code]new Object[/code] in C#, or the "Construct Object" node in VisualScript.
  9. Objects do not manage memory, if inheriting from one the object will most likely have to be deleted manually (call the [method free] function from the script or delete from C++).
  10. Some derivatives add memory management, such as [Reference] (which keeps a reference count and deletes itself automatically when no longer referenced) and [Node], which deletes the children tree when deleted.
  11. Objects export properties, which are mainly useful for storage and editing, but not really so much in programming. Properties are exported in [method _get_property_list] and handled in [method _get] and [method _set]. However, scripting languages and C++ have simpler means to export them.
  12. Objects also receive notifications ([method _notification]). Notifications are a simple way to notify the object about simple events, so they can all be handled together.
  13. </description>
  14. <tutorials>
  15. </tutorials>
  16. <demos>
  17. </demos>
  18. <methods>
  19. <method name="_get" qualifiers="virtual">
  20. <return type="Variant">
  21. </return>
  22. <argument index="0" name="property" type="String">
  23. </argument>
  24. <description>
  25. Returns the given property. Returns [code]null[/code] if the [code]property[/code] does not exist.
  26. </description>
  27. </method>
  28. <method name="_get_property_list" qualifiers="virtual">
  29. <return type="Array">
  30. </return>
  31. <description>
  32. Returns the object's property list as an [Array] of dictionaries. Dictionaries must contain: name:String, type:int (see TYPE_* enum in [@GlobalScope]) and optionally: hint:int (see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@GlobalScope]).
  33. </description>
  34. </method>
  35. <method name="_init" qualifiers="virtual">
  36. <return type="void">
  37. </return>
  38. <description>
  39. The virtual method called upon initialization.
  40. </description>
  41. </method>
  42. <method name="_notification" qualifiers="virtual">
  43. <return type="void">
  44. </return>
  45. <argument index="0" name="what" type="int">
  46. </argument>
  47. <description>
  48. Notify the object internally using an ID.
  49. </description>
  50. </method>
  51. <method name="_set" qualifiers="virtual">
  52. <return type="bool">
  53. </return>
  54. <argument index="0" name="property" type="String">
  55. </argument>
  56. <argument index="1" name="value" type="Variant">
  57. </argument>
  58. <description>
  59. Sets a property. Returns [code]true[/code] if the [code]property[/code] exists.
  60. </description>
  61. </method>
  62. <method name="add_user_signal">
  63. <return type="void">
  64. </return>
  65. <argument index="0" name="signal" type="String">
  66. </argument>
  67. <argument index="1" name="arguments" type="Array" default="[ ]">
  68. </argument>
  69. <description>
  70. Adds a user-defined [code]signal[/code]. Arguments are optional, but can be added as an [Array] of dictionaries, each containing "name" and "type" (from [@GlobalScope] TYPE_*).
  71. </description>
  72. </method>
  73. <method name="call" qualifiers="vararg">
  74. <return type="Variant">
  75. </return>
  76. <argument index="0" name="method" type="String">
  77. </argument>
  78. <description>
  79. Calls the [code]method[/code] on the object and returns a result. Pass parameters as a comma separated list.
  80. </description>
  81. </method>
  82. <method name="call_deferred" qualifiers="vararg">
  83. <return type="Variant">
  84. </return>
  85. <argument index="0" name="method" type="String">
  86. </argument>
  87. <description>
  88. Calls the [code]method[/code] on the object during idle time and returns a result. Pass parameters as a comma separated list.
  89. </description>
  90. </method>
  91. <method name="callv">
  92. <return type="Variant">
  93. </return>
  94. <argument index="0" name="method" type="String">
  95. </argument>
  96. <argument index="1" name="arg_array" type="Array">
  97. </argument>
  98. <description>
  99. Calls the [code]method[/code] on the object and returns a result. Pass parameters as an [Array].
  100. </description>
  101. </method>
  102. <method name="can_translate_messages" qualifiers="const">
  103. <return type="bool">
  104. </return>
  105. <description>
  106. Returns [code]true[/code] if the object can translate strings.
  107. </description>
  108. </method>
  109. <method name="connect">
  110. <return type="int" enum="Error">
  111. </return>
  112. <argument index="0" name="signal" type="String">
  113. </argument>
  114. <argument index="1" name="target" type="Object">
  115. </argument>
  116. <argument index="2" name="method" type="String">
  117. </argument>
  118. <argument index="3" name="binds" type="Array" default="[ ]">
  119. </argument>
  120. <argument index="4" name="flags" type="int" default="0">
  121. </argument>
  122. <description>
  123. Connects a [code]signal[/code] to a [code]method[/code] on a [code]target[/code] object. Pass optional [code]binds[/code] to the call. Use [code]flags[/code] to set deferred or one shot connections. See [code]CONNECT_*[/code] constants. A [code]signal[/code] can only be connected once to a [code]method[/code]. It will throw an error if already connected. To avoid this, first use [method is_connected] to check for existing connections.
  124. </description>
  125. </method>
  126. <method name="disconnect">
  127. <return type="void">
  128. </return>
  129. <argument index="0" name="signal" type="String">
  130. </argument>
  131. <argument index="1" name="target" type="Object">
  132. </argument>
  133. <argument index="2" name="method" type="String">
  134. </argument>
  135. <description>
  136. Disconnects a [code]signal[/code] from a [code]method[/code] on the given [code]target[/code].
  137. </description>
  138. </method>
  139. <method name="emit_signal" qualifiers="vararg">
  140. <return type="Variant">
  141. </return>
  142. <argument index="0" name="signal" type="String">
  143. </argument>
  144. <description>
  145. Emits the given [code]signal[/code].
  146. </description>
  147. </method>
  148. <method name="free">
  149. <return type="void">
  150. </return>
  151. <description>
  152. Deletes the object from memory.
  153. </description>
  154. </method>
  155. <method name="get" qualifiers="const">
  156. <return type="Variant">
  157. </return>
  158. <argument index="0" name="property" type="String">
  159. </argument>
  160. <description>
  161. Returns a [Variant] for a [code]property[/code].
  162. </description>
  163. </method>
  164. <method name="get_class" qualifiers="const">
  165. <return type="String">
  166. </return>
  167. <description>
  168. Returns the object's class as a [String].
  169. </description>
  170. </method>
  171. <method name="get_incoming_connections" qualifiers="const">
  172. <return type="Array">
  173. </return>
  174. <description>
  175. Returns an [Array] of dictionaries with information about signals that are connected to the object.
  176. Inside each [Dictionary] there are 3 fields:
  177. - "source" is a reference to signal emitter.
  178. - "signal_name" is name of connected signal.
  179. - "method_name" is a name of method to which signal is connected.
  180. </description>
  181. </method>
  182. <method name="get_indexed" qualifiers="const">
  183. <return type="Variant">
  184. </return>
  185. <argument index="0" name="property" type="NodePath">
  186. </argument>
  187. <description>
  188. Get indexed object property by String.
  189. Property indices get accessed with colon separation, for example: [code]position:x[/code]
  190. </description>
  191. </method>
  192. <method name="get_instance_id" qualifiers="const">
  193. <return type="int">
  194. </return>
  195. <description>
  196. Returns the object's unique instance ID.
  197. </description>
  198. </method>
  199. <method name="get_meta" qualifiers="const">
  200. <return type="Variant">
  201. </return>
  202. <argument index="0" name="name" type="String">
  203. </argument>
  204. <description>
  205. Returns the object's metadata for the given [code]name[/code].
  206. </description>
  207. </method>
  208. <method name="get_meta_list" qualifiers="const">
  209. <return type="PoolStringArray">
  210. </return>
  211. <description>
  212. Returns the object's metadata as a [PoolStringArray].
  213. </description>
  214. </method>
  215. <method name="get_method_list" qualifiers="const">
  216. <return type="Array">
  217. </return>
  218. <description>
  219. Returns the object's methods and their signatures as an [Array].
  220. </description>
  221. </method>
  222. <method name="get_property_list" qualifiers="const">
  223. <return type="Array">
  224. </return>
  225. <description>
  226. Returns the list of properties as an [Array] of dictionaries. Dictionaries contain: name:String, type:int (see TYPE_* enum in [@GlobalScope]) and optionally: hint:int (see PROPERTY_HINT_* in [@GlobalScope]), hint_string:String, usage:int (see PROPERTY_USAGE_* in [@GlobalScope]).
  227. </description>
  228. </method>
  229. <method name="get_script" qualifiers="const">
  230. <return type="Reference">
  231. </return>
  232. <description>
  233. Returns the object's [Script] or [code]null[/code] if one doesn't exist.
  234. </description>
  235. </method>
  236. <method name="get_signal_connection_list" qualifiers="const">
  237. <return type="Array">
  238. </return>
  239. <argument index="0" name="signal" type="String">
  240. </argument>
  241. <description>
  242. Returns an [Array] of connections for the given [code]signal[/code].
  243. </description>
  244. </method>
  245. <method name="get_signal_list" qualifiers="const">
  246. <return type="Array">
  247. </return>
  248. <description>
  249. Returns the list of signals as an [Array] of dictionaries.
  250. </description>
  251. </method>
  252. <method name="has_meta" qualifiers="const">
  253. <return type="bool">
  254. </return>
  255. <argument index="0" name="name" type="String">
  256. </argument>
  257. <description>
  258. Returns [code]true[/code] if a metadata is found with the given [code]name[/code].
  259. </description>
  260. </method>
  261. <method name="has_method" qualifiers="const">
  262. <return type="bool">
  263. </return>
  264. <argument index="0" name="method" type="String">
  265. </argument>
  266. <description>
  267. Returns [code]true[/code] if the object contains the given [code]method[/code].
  268. </description>
  269. </method>
  270. <method name="has_user_signal" qualifiers="const">
  271. <return type="bool">
  272. </return>
  273. <argument index="0" name="signal" type="String">
  274. </argument>
  275. <description>
  276. Returns [code]true[/code] if the given user-defined [code]signal[/code] exists.
  277. </description>
  278. </method>
  279. <method name="is_blocking_signals" qualifiers="const">
  280. <return type="bool">
  281. </return>
  282. <description>
  283. Returns [code]true[/code] if signal emission blocking is enabled.
  284. </description>
  285. </method>
  286. <method name="is_class" qualifiers="const">
  287. <return type="bool">
  288. </return>
  289. <argument index="0" name="type" type="String">
  290. </argument>
  291. <description>
  292. Returns [code]true[/code] if the object inherits from the given [code]type[/code].
  293. </description>
  294. </method>
  295. <method name="is_connected" qualifiers="const">
  296. <return type="bool">
  297. </return>
  298. <argument index="0" name="signal" type="String">
  299. </argument>
  300. <argument index="1" name="target" type="Object">
  301. </argument>
  302. <argument index="2" name="method" type="String">
  303. </argument>
  304. <description>
  305. Returns [code]true[/code] if a connection exists for a given [code]signal[/code], [code]target[/code], and [code]method[/code].
  306. </description>
  307. </method>
  308. <method name="is_queued_for_deletion" qualifiers="const">
  309. <return type="bool">
  310. </return>
  311. <description>
  312. Returns [code]true[/code] if the [code]queue_free[/code] method was called for the object.
  313. </description>
  314. </method>
  315. <method name="notification">
  316. <return type="void">
  317. </return>
  318. <argument index="0" name="what" type="int">
  319. </argument>
  320. <argument index="1" name="reversed" type="bool" default="false">
  321. </argument>
  322. <description>
  323. Notify the object of something.
  324. </description>
  325. </method>
  326. <method name="property_list_changed_notify">
  327. <return type="void">
  328. </return>
  329. <description>
  330. </description>
  331. </method>
  332. <method name="set">
  333. <return type="void">
  334. </return>
  335. <argument index="0" name="property" type="String">
  336. </argument>
  337. <argument index="1" name="value" type="Variant">
  338. </argument>
  339. <description>
  340. Set property into the object.
  341. </description>
  342. </method>
  343. <method name="set_block_signals">
  344. <return type="void">
  345. </return>
  346. <argument index="0" name="enable" type="bool">
  347. </argument>
  348. <description>
  349. If set to true, signal emission is blocked.
  350. </description>
  351. </method>
  352. <method name="set_deferred">
  353. <return type="void">
  354. </return>
  355. <argument index="0" name="property" type="String">
  356. </argument>
  357. <argument index="1" name="value" type="Variant">
  358. </argument>
  359. <description>
  360. </description>
  361. </method>
  362. <method name="set_indexed">
  363. <return type="void">
  364. </return>
  365. <argument index="0" name="property" type="NodePath">
  366. </argument>
  367. <argument index="1" name="value" type="Variant">
  368. </argument>
  369. <description>
  370. </description>
  371. </method>
  372. <method name="set_message_translation">
  373. <return type="void">
  374. </return>
  375. <argument index="0" name="enable" type="bool">
  376. </argument>
  377. <description>
  378. Define whether the object can translate strings (with calls to [method tr]). Default is true.
  379. </description>
  380. </method>
  381. <method name="set_meta">
  382. <return type="void">
  383. </return>
  384. <argument index="0" name="name" type="String">
  385. </argument>
  386. <argument index="1" name="value" type="Variant">
  387. </argument>
  388. <description>
  389. Set a metadata into the object. Metadata is serialized. Metadata can be [i]anything[/i].
  390. </description>
  391. </method>
  392. <method name="set_script">
  393. <return type="void">
  394. </return>
  395. <argument index="0" name="script" type="Reference">
  396. </argument>
  397. <description>
  398. Set a script into the object, scripts extend the object functionality.
  399. </description>
  400. </method>
  401. <method name="tr" qualifiers="const">
  402. <return type="String">
  403. </return>
  404. <argument index="0" name="message" type="String">
  405. </argument>
  406. <description>
  407. Translate a message. Only works if message translation is enabled (which it is by default). See [method set_message_translation].
  408. </description>
  409. </method>
  410. </methods>
  411. <signals>
  412. <signal name="script_changed">
  413. <description>
  414. Emitted whenever the script of the Object is changed.
  415. </description>
  416. </signal>
  417. </signals>
  418. <constants>
  419. <constant name="NOTIFICATION_POSTINITIALIZE" value="0">
  420. Called right when the object is initialized. Not available in script.
  421. </constant>
  422. <constant name="NOTIFICATION_PREDELETE" value="1">
  423. Called before the object is about to be deleted.
  424. </constant>
  425. <constant name="CONNECT_DEFERRED" value="1" enum="ConnectFlags">
  426. Connect a signal in deferred mode. This way, signal emissions are stored in a queue, then set on idle time.
  427. </constant>
  428. <constant name="CONNECT_PERSIST" value="2" enum="ConnectFlags">
  429. Persisting connections are saved when the object is serialized to file.
  430. </constant>
  431. <constant name="CONNECT_ONESHOT" value="4" enum="ConnectFlags">
  432. One shot connections disconnect themselves after emission.
  433. </constant>
  434. <constant name="CONNECT_REFERENCE_COUNTED" value="8" enum="ConnectFlags">
  435. </constant>
  436. </constants>
  437. </class>