class_packedbytearray.rst 66 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049
  1. :github_url: hide
  2. .. DO NOT EDIT THIS FILE!!!
  3. .. Generated automatically from Godot engine sources.
  4. .. Generator: https://github.com/godotengine/godot/tree/4.3/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.3/doc/classes/PackedByteArray.xml.
  6. .. _class_PackedByteArray:
  7. PackedByteArray
  8. ===============
  9. A packed array of bytes.
  10. .. rst-class:: classref-introduction-group
  11. Description
  12. -----------
  13. An array specifically designed to hold bytes. Packs data tightly, so it saves memory for large array sizes.
  14. \ **PackedByteArray** also provides methods to encode/decode various types to/from bytes. The way values are encoded is an implementation detail and shouldn't be relied upon when interacting with external apps.
  15. \ **Note:** Packed arrays are always passed by reference. To get a copy of an array that can be modified independently of the original array, use :ref:`duplicate<class_PackedByteArray_method_duplicate>`. This is *not* the case for built-in properties and methods. The returned packed array of these are a copies, and changing it will *not* affect the original value. To update a built-in property you need to modify the returned array, and then assign it to the property again.
  16. .. note::
  17. There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
  18. .. rst-class:: classref-reftable-group
  19. Constructors
  20. ------------
  21. .. table::
  22. :widths: auto
  23. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  24. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ ) |
  25. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  26. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ from\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  27. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  28. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ from\: :ref:`Array<class_Array>`\ ) |
  29. +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
  30. .. rst-class:: classref-reftable-group
  31. Methods
  32. -------
  33. .. table::
  34. :widths: auto
  35. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  36. | :ref:`bool<class_bool>` | :ref:`append<class_PackedByteArray_method_append>`\ (\ value\: :ref:`int<class_int>`\ ) |
  37. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  38. | |void| | :ref:`append_array<class_PackedByteArray_method_append_array>`\ (\ array\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  39. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  40. | :ref:`int<class_int>` | :ref:`bsearch<class_PackedByteArray_method_bsearch>`\ (\ value\: :ref:`int<class_int>`, before\: :ref:`bool<class_bool>` = true\ ) |
  41. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  42. | |void| | :ref:`clear<class_PackedByteArray_method_clear>`\ (\ ) |
  43. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  44. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`compress<class_PackedByteArray_method_compress>`\ (\ compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
  45. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  46. | :ref:`int<class_int>` | :ref:`count<class_PackedByteArray_method_count>`\ (\ value\: :ref:`int<class_int>`\ ) |const| |
  47. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  48. | :ref:`float<class_float>` | :ref:`decode_double<class_PackedByteArray_method_decode_double>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  49. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  50. | :ref:`float<class_float>` | :ref:`decode_float<class_PackedByteArray_method_decode_float>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  51. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  52. | :ref:`float<class_float>` | :ref:`decode_half<class_PackedByteArray_method_decode_half>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  53. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  54. | :ref:`int<class_int>` | :ref:`decode_s8<class_PackedByteArray_method_decode_s8>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  55. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  56. | :ref:`int<class_int>` | :ref:`decode_s16<class_PackedByteArray_method_decode_s16>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  57. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  58. | :ref:`int<class_int>` | :ref:`decode_s32<class_PackedByteArray_method_decode_s32>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  59. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  60. | :ref:`int<class_int>` | :ref:`decode_s64<class_PackedByteArray_method_decode_s64>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  61. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  62. | :ref:`int<class_int>` | :ref:`decode_u8<class_PackedByteArray_method_decode_u8>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  63. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  64. | :ref:`int<class_int>` | :ref:`decode_u16<class_PackedByteArray_method_decode_u16>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  65. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  66. | :ref:`int<class_int>` | :ref:`decode_u32<class_PackedByteArray_method_decode_u32>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  67. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  68. | :ref:`int<class_int>` | :ref:`decode_u64<class_PackedByteArray_method_decode_u64>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
  69. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  70. | :ref:`Variant<class_Variant>` | :ref:`decode_var<class_PackedByteArray_method_decode_var>`\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| |
  71. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  72. | :ref:`int<class_int>` | :ref:`decode_var_size<class_PackedByteArray_method_decode_var_size>`\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| |
  73. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  74. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress<class_PackedByteArray_method_decompress>`\ (\ buffer_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
  75. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  76. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress_dynamic<class_PackedByteArray_method_decompress_dynamic>`\ (\ max_output_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
  77. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  78. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`duplicate<class_PackedByteArray_method_duplicate>`\ (\ ) |
  79. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  80. | |void| | :ref:`encode_double<class_PackedByteArray_method_encode_double>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  81. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  82. | |void| | :ref:`encode_float<class_PackedByteArray_method_encode_float>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  83. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  84. | |void| | :ref:`encode_half<class_PackedByteArray_method_encode_half>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
  85. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  86. | |void| | :ref:`encode_s8<class_PackedByteArray_method_encode_s8>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  87. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  88. | |void| | :ref:`encode_s16<class_PackedByteArray_method_encode_s16>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  89. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  90. | |void| | :ref:`encode_s32<class_PackedByteArray_method_encode_s32>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  91. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  92. | |void| | :ref:`encode_s64<class_PackedByteArray_method_encode_s64>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  93. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  94. | |void| | :ref:`encode_u8<class_PackedByteArray_method_encode_u8>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  95. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  96. | |void| | :ref:`encode_u16<class_PackedByteArray_method_encode_u16>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  97. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  98. | |void| | :ref:`encode_u32<class_PackedByteArray_method_encode_u32>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  99. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  100. | |void| | :ref:`encode_u64<class_PackedByteArray_method_encode_u64>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  101. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  102. | :ref:`int<class_int>` | :ref:`encode_var<class_PackedByteArray_method_encode_var>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`Variant<class_Variant>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |
  103. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  104. | |void| | :ref:`fill<class_PackedByteArray_method_fill>`\ (\ value\: :ref:`int<class_int>`\ ) |
  105. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  106. | :ref:`int<class_int>` | :ref:`find<class_PackedByteArray_method_find>`\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = 0\ ) |const| |
  107. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  108. | :ref:`String<class_String>` | :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>`\ (\ ) |const| |
  109. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  110. | :ref:`String<class_String>` | :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>`\ (\ ) |const| |
  111. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  112. | :ref:`String<class_String>` | :ref:`get_string_from_utf16<class_PackedByteArray_method_get_string_from_utf16>`\ (\ ) |const| |
  113. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  114. | :ref:`String<class_String>` | :ref:`get_string_from_utf32<class_PackedByteArray_method_get_string_from_utf32>`\ (\ ) |const| |
  115. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  116. | :ref:`String<class_String>` | :ref:`get_string_from_wchar<class_PackedByteArray_method_get_string_from_wchar>`\ (\ ) |const| |
  117. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  118. | :ref:`bool<class_bool>` | :ref:`has<class_PackedByteArray_method_has>`\ (\ value\: :ref:`int<class_int>`\ ) |const| |
  119. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  120. | :ref:`bool<class_bool>` | :ref:`has_encoded_var<class_PackedByteArray_method_has_encoded_var>`\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| |
  121. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  122. | :ref:`String<class_String>` | :ref:`hex_encode<class_PackedByteArray_method_hex_encode>`\ (\ ) |const| |
  123. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  124. | :ref:`int<class_int>` | :ref:`insert<class_PackedByteArray_method_insert>`\ (\ at_index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  125. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  126. | :ref:`bool<class_bool>` | :ref:`is_empty<class_PackedByteArray_method_is_empty>`\ (\ ) |const| |
  127. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  128. | :ref:`bool<class_bool>` | :ref:`push_back<class_PackedByteArray_method_push_back>`\ (\ value\: :ref:`int<class_int>`\ ) |
  129. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  130. | |void| | :ref:`remove_at<class_PackedByteArray_method_remove_at>`\ (\ index\: :ref:`int<class_int>`\ ) |
  131. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  132. | :ref:`int<class_int>` | :ref:`resize<class_PackedByteArray_method_resize>`\ (\ new_size\: :ref:`int<class_int>`\ ) |
  133. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  134. | |void| | :ref:`reverse<class_PackedByteArray_method_reverse>`\ (\ ) |
  135. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  136. | :ref:`int<class_int>` | :ref:`rfind<class_PackedByteArray_method_rfind>`\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = -1\ ) |const| |
  137. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  138. | |void| | :ref:`set<class_PackedByteArray_method_set>`\ (\ index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
  139. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  140. | :ref:`int<class_int>` | :ref:`size<class_PackedByteArray_method_size>`\ (\ ) |const| |
  141. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  142. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`slice<class_PackedByteArray_method_slice>`\ (\ begin\: :ref:`int<class_int>`, end\: :ref:`int<class_int>` = 2147483647\ ) |const| |
  143. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  144. | |void| | :ref:`sort<class_PackedByteArray_method_sort>`\ (\ ) |
  145. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  146. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`to_float32_array<class_PackedByteArray_method_to_float32_array>`\ (\ ) |const| |
  147. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  148. | :ref:`PackedFloat64Array<class_PackedFloat64Array>` | :ref:`to_float64_array<class_PackedByteArray_method_to_float64_array>`\ (\ ) |const| |
  149. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  150. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`to_int32_array<class_PackedByteArray_method_to_int32_array>`\ (\ ) |const| |
  151. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  152. | :ref:`PackedInt64Array<class_PackedInt64Array>` | :ref:`to_int64_array<class_PackedByteArray_method_to_int64_array>`\ (\ ) |const| |
  153. +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  154. .. rst-class:: classref-reftable-group
  155. Operators
  156. ---------
  157. .. table::
  158. :widths: auto
  159. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  160. | :ref:`bool<class_bool>` | :ref:`operator !=<class_PackedByteArray_operator_neq_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  161. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  162. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`operator +<class_PackedByteArray_operator_sum_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  163. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  164. | :ref:`bool<class_bool>` | :ref:`operator ==<class_PackedByteArray_operator_eq_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
  165. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  166. | :ref:`int<class_int>` | :ref:`operator []<class_PackedByteArray_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
  167. +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
  168. .. rst-class:: classref-section-separator
  169. ----
  170. .. rst-class:: classref-descriptions-group
  171. Constructor Descriptions
  172. ------------------------
  173. .. _class_PackedByteArray_constructor_PackedByteArray:
  174. .. rst-class:: classref-constructor
  175. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ ) :ref:`🔗<class_PackedByteArray_constructor_PackedByteArray>`
  176. Constructs an empty **PackedByteArray**.
  177. .. rst-class:: classref-item-separator
  178. ----
  179. .. rst-class:: classref-constructor
  180. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ from\: :ref:`PackedByteArray<class_PackedByteArray>`\ )
  181. Constructs a **PackedByteArray** as a copy of the given **PackedByteArray**.
  182. .. rst-class:: classref-item-separator
  183. ----
  184. .. rst-class:: classref-constructor
  185. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ from\: :ref:`Array<class_Array>`\ )
  186. Constructs a new **PackedByteArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  187. .. rst-class:: classref-section-separator
  188. ----
  189. .. rst-class:: classref-descriptions-group
  190. Method Descriptions
  191. -------------------
  192. .. _class_PackedByteArray_method_append:
  193. .. rst-class:: classref-method
  194. :ref:`bool<class_bool>` **append**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_append>`
  195. Appends an element at the end of the array (alias of :ref:`push_back<class_PackedByteArray_method_push_back>`).
  196. .. rst-class:: classref-item-separator
  197. ----
  198. .. _class_PackedByteArray_method_append_array:
  199. .. rst-class:: classref-method
  200. |void| **append_array**\ (\ array\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_method_append_array>`
  201. Appends a **PackedByteArray** at the end of this array.
  202. .. rst-class:: classref-item-separator
  203. ----
  204. .. _class_PackedByteArray_method_bsearch:
  205. .. rst-class:: classref-method
  206. :ref:`int<class_int>` **bsearch**\ (\ value\: :ref:`int<class_int>`, before\: :ref:`bool<class_bool>` = true\ ) :ref:`🔗<class_PackedByteArray_method_bsearch>`
  207. Finds the index of an existing value (or the insertion index that maintains sorting order, if the value is not yet present in the array) using binary search. Optionally, a ``before`` specifier can be passed. If ``false``, the returned index comes after all existing entries of the value in the array.
  208. \ **Note:** Calling :ref:`bsearch<class_PackedByteArray_method_bsearch>` on an unsorted array results in unexpected behavior.
  209. .. rst-class:: classref-item-separator
  210. ----
  211. .. _class_PackedByteArray_method_clear:
  212. .. rst-class:: classref-method
  213. |void| **clear**\ (\ ) :ref:`🔗<class_PackedByteArray_method_clear>`
  214. Clears the array. This is equivalent to using :ref:`resize<class_PackedByteArray_method_resize>` with a size of ``0``.
  215. .. rst-class:: classref-item-separator
  216. ----
  217. .. _class_PackedByteArray_method_compress:
  218. .. rst-class:: classref-method
  219. :ref:`PackedByteArray<class_PackedByteArray>` **compress**\ (\ compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_compress>`
  220. Returns a new **PackedByteArray** with the data compressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  221. .. rst-class:: classref-item-separator
  222. ----
  223. .. _class_PackedByteArray_method_count:
  224. .. rst-class:: classref-method
  225. :ref:`int<class_int>` **count**\ (\ value\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_count>`
  226. Returns the number of times an element is in the array.
  227. .. rst-class:: classref-item-separator
  228. ----
  229. .. _class_PackedByteArray_method_decode_double:
  230. .. rst-class:: classref-method
  231. :ref:`float<class_float>` **decode_double**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_double>`
  232. Decodes a 64-bit floating-point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  233. .. rst-class:: classref-item-separator
  234. ----
  235. .. _class_PackedByteArray_method_decode_float:
  236. .. rst-class:: classref-method
  237. :ref:`float<class_float>` **decode_float**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_float>`
  238. Decodes a 32-bit floating-point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  239. .. rst-class:: classref-item-separator
  240. ----
  241. .. _class_PackedByteArray_method_decode_half:
  242. .. rst-class:: classref-method
  243. :ref:`float<class_float>` **decode_half**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_half>`
  244. Decodes a 16-bit floating-point number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0.0`` if a valid number can't be decoded.
  245. .. rst-class:: classref-item-separator
  246. ----
  247. .. _class_PackedByteArray_method_decode_s8:
  248. .. rst-class:: classref-method
  249. :ref:`int<class_int>` **decode_s8**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s8>`
  250. Decodes a 8-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  251. .. rst-class:: classref-item-separator
  252. ----
  253. .. _class_PackedByteArray_method_decode_s16:
  254. .. rst-class:: classref-method
  255. :ref:`int<class_int>` **decode_s16**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s16>`
  256. Decodes a 16-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  257. .. rst-class:: classref-item-separator
  258. ----
  259. .. _class_PackedByteArray_method_decode_s32:
  260. .. rst-class:: classref-method
  261. :ref:`int<class_int>` **decode_s32**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s32>`
  262. Decodes a 32-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  263. .. rst-class:: classref-item-separator
  264. ----
  265. .. _class_PackedByteArray_method_decode_s64:
  266. .. rst-class:: classref-method
  267. :ref:`int<class_int>` **decode_s64**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_s64>`
  268. Decodes a 64-bit signed integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  269. .. rst-class:: classref-item-separator
  270. ----
  271. .. _class_PackedByteArray_method_decode_u8:
  272. .. rst-class:: classref-method
  273. :ref:`int<class_int>` **decode_u8**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u8>`
  274. Decodes a 8-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  275. .. rst-class:: classref-item-separator
  276. ----
  277. .. _class_PackedByteArray_method_decode_u16:
  278. .. rst-class:: classref-method
  279. :ref:`int<class_int>` **decode_u16**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u16>`
  280. Decodes a 16-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  281. .. rst-class:: classref-item-separator
  282. ----
  283. .. _class_PackedByteArray_method_decode_u32:
  284. .. rst-class:: classref-method
  285. :ref:`int<class_int>` **decode_u32**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u32>`
  286. Decodes a 32-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  287. .. rst-class:: classref-item-separator
  288. ----
  289. .. _class_PackedByteArray_method_decode_u64:
  290. .. rst-class:: classref-method
  291. :ref:`int<class_int>` **decode_u64**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_u64>`
  292. Decodes a 64-bit unsigned integer number from the bytes starting at ``byte_offset``. Fails if the byte count is insufficient. Returns ``0`` if a valid number can't be decoded.
  293. .. rst-class:: classref-item-separator
  294. ----
  295. .. _class_PackedByteArray_method_decode_var:
  296. .. rst-class:: classref-method
  297. :ref:`Variant<class_Variant>` **decode_var**\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_var>`
  298. Decodes a :ref:`Variant<class_Variant>` from the bytes starting at ``byte_offset``. Returns ``null`` if a valid variant can't be decoded or the value is :ref:`Object<class_Object>`-derived and ``allow_objects`` is ``false``.
  299. .. rst-class:: classref-item-separator
  300. ----
  301. .. _class_PackedByteArray_method_decode_var_size:
  302. .. rst-class:: classref-method
  303. :ref:`int<class_int>` **decode_var_size**\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_PackedByteArray_method_decode_var_size>`
  304. Decodes a size of a :ref:`Variant<class_Variant>` from the bytes starting at ``byte_offset``. Requires at least 4 bytes of data starting at the offset, otherwise fails.
  305. .. rst-class:: classref-item-separator
  306. ----
  307. .. _class_PackedByteArray_method_decompress:
  308. .. rst-class:: classref-method
  309. :ref:`PackedByteArray<class_PackedByteArray>` **decompress**\ (\ buffer_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_decompress>`
  310. Returns a new **PackedByteArray** with the data decompressed. Set ``buffer_size`` to the size of the uncompressed data. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  311. \ **Note:** Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
  312. .. rst-class:: classref-item-separator
  313. ----
  314. .. _class_PackedByteArray_method_decompress_dynamic:
  315. .. rst-class:: classref-method
  316. :ref:`PackedByteArray<class_PackedByteArray>` **decompress_dynamic**\ (\ max_output_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_decompress_dynamic>`
  317. Returns a new **PackedByteArray** with the data decompressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants. **This method only accepts brotli, gzip, and deflate compression modes.**\
  318. This method is potentially slower than :ref:`decompress<class_PackedByteArray_method_decompress>`, as it may have to re-allocate its output buffer multiple times while decompressing, whereas :ref:`decompress<class_PackedByteArray_method_decompress>` knows it's output buffer size from the beginning.
  319. GZIP has a maximal compression ratio of 1032:1, meaning it's very possible for a small compressed payload to decompress to a potentially very large output. To guard against this, you may provide a maximum size this function is allowed to allocate in bytes via ``max_output_size``. Passing -1 will allow for unbounded output. If any positive value is passed, and the decompression exceeds that amount in bytes, then an error will be returned.
  320. \ **Note:** Decompression is not guaranteed to work with data not compressed by Godot, for example if data compressed with the deflate compression mode lacks a checksum or header.
  321. .. rst-class:: classref-item-separator
  322. ----
  323. .. _class_PackedByteArray_method_duplicate:
  324. .. rst-class:: classref-method
  325. :ref:`PackedByteArray<class_PackedByteArray>` **duplicate**\ (\ ) :ref:`🔗<class_PackedByteArray_method_duplicate>`
  326. Creates a copy of the array, and returns it.
  327. .. rst-class:: classref-item-separator
  328. ----
  329. .. _class_PackedByteArray_method_encode_double:
  330. .. rst-class:: classref-method
  331. |void| **encode_double**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_double>`
  332. Encodes a 64-bit floating-point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of allocated space, starting at the offset.
  333. .. rst-class:: classref-item-separator
  334. ----
  335. .. _class_PackedByteArray_method_encode_float:
  336. .. rst-class:: classref-method
  337. |void| **encode_float**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_float>`
  338. Encodes a 32-bit floating-point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  339. .. rst-class:: classref-item-separator
  340. ----
  341. .. _class_PackedByteArray_method_encode_half:
  342. .. rst-class:: classref-method
  343. |void| **encode_half**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_half>`
  344. Encodes a 16-bit floating-point number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  345. .. rst-class:: classref-item-separator
  346. ----
  347. .. _class_PackedByteArray_method_encode_s8:
  348. .. rst-class:: classref-method
  349. |void| **encode_s8**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s8>`
  350. Encodes a 8-bit signed integer number (signed byte) at the index of ``byte_offset`` bytes. The array must have at least 1 byte of space, starting at the offset.
  351. .. rst-class:: classref-item-separator
  352. ----
  353. .. _class_PackedByteArray_method_encode_s16:
  354. .. rst-class:: classref-method
  355. |void| **encode_s16**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s16>`
  356. Encodes a 16-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  357. .. rst-class:: classref-item-separator
  358. ----
  359. .. _class_PackedByteArray_method_encode_s32:
  360. .. rst-class:: classref-method
  361. |void| **encode_s32**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s32>`
  362. Encodes a 32-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  363. .. rst-class:: classref-item-separator
  364. ----
  365. .. _class_PackedByteArray_method_encode_s64:
  366. .. rst-class:: classref-method
  367. |void| **encode_s64**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_s64>`
  368. Encodes a 64-bit signed integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of space, starting at the offset.
  369. .. rst-class:: classref-item-separator
  370. ----
  371. .. _class_PackedByteArray_method_encode_u8:
  372. .. rst-class:: classref-method
  373. |void| **encode_u8**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u8>`
  374. Encodes a 8-bit unsigned integer number (byte) at the index of ``byte_offset`` bytes. The array must have at least 1 byte of space, starting at the offset.
  375. .. rst-class:: classref-item-separator
  376. ----
  377. .. _class_PackedByteArray_method_encode_u16:
  378. .. rst-class:: classref-method
  379. |void| **encode_u16**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u16>`
  380. Encodes a 16-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 2 bytes of space, starting at the offset.
  381. .. rst-class:: classref-item-separator
  382. ----
  383. .. _class_PackedByteArray_method_encode_u32:
  384. .. rst-class:: classref-method
  385. |void| **encode_u32**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u32>`
  386. Encodes a 32-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 4 bytes of space, starting at the offset.
  387. .. rst-class:: classref-item-separator
  388. ----
  389. .. _class_PackedByteArray_method_encode_u64:
  390. .. rst-class:: classref-method
  391. |void| **encode_u64**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_encode_u64>`
  392. Encodes a 64-bit unsigned integer number as bytes at the index of ``byte_offset`` bytes. The array must have at least 8 bytes of space, starting at the offset.
  393. .. rst-class:: classref-item-separator
  394. ----
  395. .. _class_PackedByteArray_method_encode_var:
  396. .. rst-class:: classref-method
  397. :ref:`int<class_int>` **encode_var**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`Variant<class_Variant>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) :ref:`🔗<class_PackedByteArray_method_encode_var>`
  398. Encodes a :ref:`Variant<class_Variant>` at the index of ``byte_offset`` bytes. A sufficient space must be allocated, depending on the encoded variant's size. If ``allow_objects`` is ``false``, :ref:`Object<class_Object>`-derived values are not permitted and will instead be serialized as ID-only.
  399. .. rst-class:: classref-item-separator
  400. ----
  401. .. _class_PackedByteArray_method_fill:
  402. .. rst-class:: classref-method
  403. |void| **fill**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_fill>`
  404. Assigns the given value to all elements in the array. This can typically be used together with :ref:`resize<class_PackedByteArray_method_resize>` to create an array with a given size and initialized elements.
  405. .. rst-class:: classref-item-separator
  406. ----
  407. .. _class_PackedByteArray_method_find:
  408. .. rst-class:: classref-method
  409. :ref:`int<class_int>` **find**\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = 0\ ) |const| :ref:`🔗<class_PackedByteArray_method_find>`
  410. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
  411. .. rst-class:: classref-item-separator
  412. ----
  413. .. _class_PackedByteArray_method_get_string_from_ascii:
  414. .. rst-class:: classref-method
  415. :ref:`String<class_String>` **get_string_from_ascii**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_ascii>`
  416. Converts ASCII/Latin-1 encoded array to :ref:`String<class_String>`. Fast alternative to :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>` if the content is ASCII/Latin-1 only. Unlike the UTF-8 function this function maps every byte to a character in the array. Multibyte sequences will not be interpreted correctly. For parsing user input always use :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>`. This is the inverse of :ref:`String.to_ascii_buffer<class_String_method_to_ascii_buffer>`.
  417. .. rst-class:: classref-item-separator
  418. ----
  419. .. _class_PackedByteArray_method_get_string_from_utf8:
  420. .. rst-class:: classref-method
  421. :ref:`String<class_String>` **get_string_from_utf8**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_utf8>`
  422. Converts UTF-8 encoded array to :ref:`String<class_String>`. Slower than :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>` but supports UTF-8 encoded data. Use this function if you are unsure about the source of the data. For user input this function should always be preferred. Returns empty string if source array is not valid UTF-8 string. This is the inverse of :ref:`String.to_utf8_buffer<class_String_method_to_utf8_buffer>`.
  423. .. rst-class:: classref-item-separator
  424. ----
  425. .. _class_PackedByteArray_method_get_string_from_utf16:
  426. .. rst-class:: classref-method
  427. :ref:`String<class_String>` **get_string_from_utf16**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_utf16>`
  428. Converts UTF-16 encoded array to :ref:`String<class_String>`. If the BOM is missing, system endianness is assumed. Returns empty string if source array is not valid UTF-16 string. This is the inverse of :ref:`String.to_utf16_buffer<class_String_method_to_utf16_buffer>`.
  429. .. rst-class:: classref-item-separator
  430. ----
  431. .. _class_PackedByteArray_method_get_string_from_utf32:
  432. .. rst-class:: classref-method
  433. :ref:`String<class_String>` **get_string_from_utf32**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_utf32>`
  434. Converts UTF-32 encoded array to :ref:`String<class_String>`. System endianness is assumed. Returns empty string if source array is not valid UTF-32 string. This is the inverse of :ref:`String.to_utf32_buffer<class_String_method_to_utf32_buffer>`.
  435. .. rst-class:: classref-item-separator
  436. ----
  437. .. _class_PackedByteArray_method_get_string_from_wchar:
  438. .. rst-class:: classref-method
  439. :ref:`String<class_String>` **get_string_from_wchar**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_get_string_from_wchar>`
  440. Converts wide character (``wchar_t``, UTF-16 on Windows, UTF-32 on other platforms) encoded array to :ref:`String<class_String>`. Returns empty string if source array is not valid wide string. This is the inverse of :ref:`String.to_wchar_buffer<class_String_method_to_wchar_buffer>`.
  441. .. rst-class:: classref-item-separator
  442. ----
  443. .. _class_PackedByteArray_method_has:
  444. .. rst-class:: classref-method
  445. :ref:`bool<class_bool>` **has**\ (\ value\: :ref:`int<class_int>`\ ) |const| :ref:`🔗<class_PackedByteArray_method_has>`
  446. Returns ``true`` if the array contains ``value``.
  447. .. rst-class:: classref-item-separator
  448. ----
  449. .. _class_PackedByteArray_method_has_encoded_var:
  450. .. rst-class:: classref-method
  451. :ref:`bool<class_bool>` **has_encoded_var**\ (\ byte_offset\: :ref:`int<class_int>`, allow_objects\: :ref:`bool<class_bool>` = false\ ) |const| :ref:`🔗<class_PackedByteArray_method_has_encoded_var>`
  452. Returns ``true`` if a valid :ref:`Variant<class_Variant>` value can be decoded at the ``byte_offset``. Returns ``false`` otherwise or when the value is :ref:`Object<class_Object>`-derived and ``allow_objects`` is ``false``.
  453. .. rst-class:: classref-item-separator
  454. ----
  455. .. _class_PackedByteArray_method_hex_encode:
  456. .. rst-class:: classref-method
  457. :ref:`String<class_String>` **hex_encode**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_hex_encode>`
  458. Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
  459. .. tabs::
  460. .. code-tab:: gdscript
  461. var array = PackedByteArray([11, 46, 255])
  462. print(array.hex_encode()) # Prints: 0b2eff
  463. .. code-tab:: csharp
  464. var array = new byte[] {11, 46, 255};
  465. GD.Print(array.HexEncode()); // Prints: 0b2eff
  466. .. rst-class:: classref-item-separator
  467. ----
  468. .. _class_PackedByteArray_method_insert:
  469. .. rst-class:: classref-method
  470. :ref:`int<class_int>` **insert**\ (\ at_index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_insert>`
  471. Inserts a new element at a given position in the array. The position must be valid, or at the end of the array (``idx == size()``).
  472. .. rst-class:: classref-item-separator
  473. ----
  474. .. _class_PackedByteArray_method_is_empty:
  475. .. rst-class:: classref-method
  476. :ref:`bool<class_bool>` **is_empty**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_is_empty>`
  477. Returns ``true`` if the array is empty.
  478. .. rst-class:: classref-item-separator
  479. ----
  480. .. _class_PackedByteArray_method_push_back:
  481. .. rst-class:: classref-method
  482. :ref:`bool<class_bool>` **push_back**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_push_back>`
  483. Appends an element at the end of the array.
  484. .. rst-class:: classref-item-separator
  485. ----
  486. .. _class_PackedByteArray_method_remove_at:
  487. .. rst-class:: classref-method
  488. |void| **remove_at**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_remove_at>`
  489. Removes an element from the array by index.
  490. .. rst-class:: classref-item-separator
  491. ----
  492. .. _class_PackedByteArray_method_resize:
  493. .. rst-class:: classref-method
  494. :ref:`int<class_int>` **resize**\ (\ new_size\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_resize>`
  495. Sets the size of the array. If the array is grown, reserves elements at the end of the array. If the array is shrunk, truncates the array to the new size. Calling :ref:`resize<class_PackedByteArray_method_resize>` once and assigning the new values is faster than adding new elements one by one.
  496. .. rst-class:: classref-item-separator
  497. ----
  498. .. _class_PackedByteArray_method_reverse:
  499. .. rst-class:: classref-method
  500. |void| **reverse**\ (\ ) :ref:`🔗<class_PackedByteArray_method_reverse>`
  501. Reverses the order of the elements in the array.
  502. .. rst-class:: classref-item-separator
  503. ----
  504. .. _class_PackedByteArray_method_rfind:
  505. .. rst-class:: classref-method
  506. :ref:`int<class_int>` **rfind**\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = -1\ ) |const| :ref:`🔗<class_PackedByteArray_method_rfind>`
  507. Searches the array in reverse order. Optionally, a start search index can be passed. If negative, the start index is considered relative to the end of the array.
  508. .. rst-class:: classref-item-separator
  509. ----
  510. .. _class_PackedByteArray_method_set:
  511. .. rst-class:: classref-method
  512. |void| **set**\ (\ index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_method_set>`
  513. Changes the byte at the given index.
  514. .. rst-class:: classref-item-separator
  515. ----
  516. .. _class_PackedByteArray_method_size:
  517. .. rst-class:: classref-method
  518. :ref:`int<class_int>` **size**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_size>`
  519. Returns the number of elements in the array.
  520. .. rst-class:: classref-item-separator
  521. ----
  522. .. _class_PackedByteArray_method_slice:
  523. .. rst-class:: classref-method
  524. :ref:`PackedByteArray<class_PackedByteArray>` **slice**\ (\ begin\: :ref:`int<class_int>`, end\: :ref:`int<class_int>` = 2147483647\ ) |const| :ref:`🔗<class_PackedByteArray_method_slice>`
  525. Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
  526. The absolute value of ``begin`` and ``end`` will be clamped to the array size, so the default value for ``end`` makes it slice to the size of the array by default (i.e. ``arr.slice(1)`` is a shorthand for ``arr.slice(1, arr.size())``).
  527. If either ``begin`` or ``end`` are negative, they will be relative to the end of the array (i.e. ``arr.slice(0, -2)`` is a shorthand for ``arr.slice(0, arr.size() - 2)``).
  528. .. rst-class:: classref-item-separator
  529. ----
  530. .. _class_PackedByteArray_method_sort:
  531. .. rst-class:: classref-method
  532. |void| **sort**\ (\ ) :ref:`🔗<class_PackedByteArray_method_sort>`
  533. Sorts the elements of the array in ascending order.
  534. .. rst-class:: classref-item-separator
  535. ----
  536. .. _class_PackedByteArray_method_to_float32_array:
  537. .. rst-class:: classref-method
  538. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_float32_array>`
  539. Returns a copy of the data converted to a :ref:`PackedFloat32Array<class_PackedFloat32Array>`, where each block of 4 bytes has been converted to a 32-bit float (C++ ``float``).
  540. The size of the input array must be a multiple of 4 (size of 32-bit float). The size of the new array will be ``byte_array.size() / 4``.
  541. If the original data can't be converted to 32-bit floats, the resulting data is undefined.
  542. .. rst-class:: classref-item-separator
  543. ----
  544. .. _class_PackedByteArray_method_to_float64_array:
  545. .. rst-class:: classref-method
  546. :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_float64_array>`
  547. Returns a copy of the data converted to a :ref:`PackedFloat64Array<class_PackedFloat64Array>`, where each block of 8 bytes has been converted to a 64-bit float (C++ ``double``, Godot :ref:`float<class_float>`).
  548. The size of the input array must be a multiple of 8 (size of 64-bit double). The size of the new array will be ``byte_array.size() / 8``.
  549. If the original data can't be converted to 64-bit floats, the resulting data is undefined.
  550. .. rst-class:: classref-item-separator
  551. ----
  552. .. _class_PackedByteArray_method_to_int32_array:
  553. .. rst-class:: classref-method
  554. :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_int32_array>`
  555. Returns a copy of the data converted to a :ref:`PackedInt32Array<class_PackedInt32Array>`, where each block of 4 bytes has been converted to a signed 32-bit integer (C++ ``int32_t``).
  556. The size of the input array must be a multiple of 4 (size of 32-bit integer). The size of the new array will be ``byte_array.size() / 4``.
  557. If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
  558. .. rst-class:: classref-item-separator
  559. ----
  560. .. _class_PackedByteArray_method_to_int64_array:
  561. .. rst-class:: classref-method
  562. :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array**\ (\ ) |const| :ref:`🔗<class_PackedByteArray_method_to_int64_array>`
  563. Returns a copy of the data converted to a :ref:`PackedInt64Array<class_PackedInt64Array>`, where each block of 8 bytes has been converted to a signed 64-bit integer (C++ ``int64_t``, Godot :ref:`int<class_int>`).
  564. The size of the input array must be a multiple of 8 (size of 64-bit integer). The size of the new array will be ``byte_array.size() / 8``.
  565. If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
  566. .. rst-class:: classref-section-separator
  567. ----
  568. .. rst-class:: classref-descriptions-group
  569. Operator Descriptions
  570. ---------------------
  571. .. _class_PackedByteArray_operator_neq_PackedByteArray:
  572. .. rst-class:: classref-operator
  573. :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_operator_neq_PackedByteArray>`
  574. Returns ``true`` if contents of the arrays differ.
  575. .. rst-class:: classref-item-separator
  576. ----
  577. .. _class_PackedByteArray_operator_sum_PackedByteArray:
  578. .. rst-class:: classref-operator
  579. :ref:`PackedByteArray<class_PackedByteArray>` **operator +**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_operator_sum_PackedByteArray>`
  580. Returns a new **PackedByteArray** with contents of ``right`` added at the end of this array. For better performance, consider using :ref:`append_array<class_PackedByteArray_method_append_array>` instead.
  581. .. rst-class:: classref-item-separator
  582. ----
  583. .. _class_PackedByteArray_operator_eq_PackedByteArray:
  584. .. rst-class:: classref-operator
  585. :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`🔗<class_PackedByteArray_operator_eq_PackedByteArray>`
  586. Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
  587. .. rst-class:: classref-item-separator
  588. ----
  589. .. _class_PackedByteArray_operator_idx_int:
  590. .. rst-class:: classref-operator
  591. :ref:`int<class_int>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`🔗<class_PackedByteArray_operator_idx_int>`
  592. Returns the byte at index ``index``. Negative indices can be used to access the elements starting from the end. Using index out of array's bounds will result in an error.
  593. Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
  594. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  595. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  596. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  597. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  598. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  599. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  600. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
  601. .. |void| replace:: :abbr:`void (No return value.)`