class_packedbytearray.rst 62 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047
  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.2/doc/tools/make_rst.py.
  5. .. XML source: https://github.com/godotengine/godot/tree/4.2/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::
  16. There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
  17. .. rst-class:: classref-reftable-group
  18. Constructors
  19. ------------
  20. .. table::
  21. :widths: auto
  22. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  23. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>` **(** **)** |
  24. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  25. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)** |
  26. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  27. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>` **(** :ref:`Array<class_Array>` from **)** |
  28. +-----------------------------------------------+------------------------------------------------------------------------------------------------------------------------------------------+
  29. .. rst-class:: classref-reftable-group
  30. Methods
  31. -------
  32. .. table::
  33. :widths: auto
  34. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  35. | :ref:`bool<class_bool>` | :ref:`append<class_PackedByteArray_method_append>` **(** :ref:`int<class_int>` value **)** |
  36. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  37. | void | :ref:`append_array<class_PackedByteArray_method_append_array>` **(** :ref:`PackedByteArray<class_PackedByteArray>` array **)** |
  38. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  39. | :ref:`int<class_int>` | :ref:`bsearch<class_PackedByteArray_method_bsearch>` **(** :ref:`int<class_int>` value, :ref:`bool<class_bool>` before=true **)** |
  40. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  41. | void | :ref:`clear<class_PackedByteArray_method_clear>` **(** **)** |
  42. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  43. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`compress<class_PackedByteArray_method_compress>` **(** :ref:`int<class_int>` compression_mode=0 **)** |const| |
  44. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  45. | :ref:`int<class_int>` | :ref:`count<class_PackedByteArray_method_count>` **(** :ref:`int<class_int>` value **)** |const| |
  46. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  47. | :ref:`float<class_float>` | :ref:`decode_double<class_PackedByteArray_method_decode_double>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  48. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  49. | :ref:`float<class_float>` | :ref:`decode_float<class_PackedByteArray_method_decode_float>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  50. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  51. | :ref:`float<class_float>` | :ref:`decode_half<class_PackedByteArray_method_decode_half>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  52. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  53. | :ref:`int<class_int>` | :ref:`decode_s8<class_PackedByteArray_method_decode_s8>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  54. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  55. | :ref:`int<class_int>` | :ref:`decode_s16<class_PackedByteArray_method_decode_s16>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  56. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  57. | :ref:`int<class_int>` | :ref:`decode_s32<class_PackedByteArray_method_decode_s32>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  58. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  59. | :ref:`int<class_int>` | :ref:`decode_s64<class_PackedByteArray_method_decode_s64>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  60. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  61. | :ref:`int<class_int>` | :ref:`decode_u8<class_PackedByteArray_method_decode_u8>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  62. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  63. | :ref:`int<class_int>` | :ref:`decode_u16<class_PackedByteArray_method_decode_u16>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  64. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  65. | :ref:`int<class_int>` | :ref:`decode_u32<class_PackedByteArray_method_decode_u32>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  66. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  67. | :ref:`int<class_int>` | :ref:`decode_u64<class_PackedByteArray_method_decode_u64>` **(** :ref:`int<class_int>` byte_offset **)** |const| |
  68. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  69. | :ref:`Variant<class_Variant>` | :ref:`decode_var<class_PackedByteArray_method_decode_var>` **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  70. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  71. | :ref:`int<class_int>` | :ref:`decode_var_size<class_PackedByteArray_method_decode_var_size>` **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  72. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  73. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress<class_PackedByteArray_method_decompress>` **(** :ref:`int<class_int>` buffer_size, :ref:`int<class_int>` compression_mode=0 **)** |const| |
  74. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  75. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress_dynamic<class_PackedByteArray_method_decompress_dynamic>` **(** :ref:`int<class_int>` max_output_size, :ref:`int<class_int>` compression_mode=0 **)** |const| |
  76. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  77. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`duplicate<class_PackedByteArray_method_duplicate>` **(** **)** |
  78. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  79. | void | :ref:`encode_double<class_PackedByteArray_method_encode_double>` **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)** |
  80. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  81. | void | :ref:`encode_float<class_PackedByteArray_method_encode_float>` **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)** |
  82. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  83. | void | :ref:`encode_half<class_PackedByteArray_method_encode_half>` **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)** |
  84. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  85. | void | :ref:`encode_s8<class_PackedByteArray_method_encode_s8>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  86. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  87. | void | :ref:`encode_s16<class_PackedByteArray_method_encode_s16>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  88. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  89. | void | :ref:`encode_s32<class_PackedByteArray_method_encode_s32>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  90. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  91. | void | :ref:`encode_s64<class_PackedByteArray_method_encode_s64>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  92. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  93. | void | :ref:`encode_u8<class_PackedByteArray_method_encode_u8>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  94. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  95. | void | :ref:`encode_u16<class_PackedByteArray_method_encode_u16>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  96. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  97. | void | :ref:`encode_u32<class_PackedByteArray_method_encode_u32>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  98. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  99. | void | :ref:`encode_u64<class_PackedByteArray_method_encode_u64>` **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)** |
  100. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  101. | :ref:`int<class_int>` | :ref:`encode_var<class_PackedByteArray_method_encode_var>` **(** :ref:`int<class_int>` byte_offset, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` allow_objects=false **)** |
  102. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  103. | void | :ref:`fill<class_PackedByteArray_method_fill>` **(** :ref:`int<class_int>` value **)** |
  104. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  105. | :ref:`int<class_int>` | :ref:`find<class_PackedByteArray_method_find>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |const| |
  106. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  107. | :ref:`String<class_String>` | :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>` **(** **)** |const| |
  108. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  109. | :ref:`String<class_String>` | :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>` **(** **)** |const| |
  110. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  111. | :ref:`String<class_String>` | :ref:`get_string_from_utf16<class_PackedByteArray_method_get_string_from_utf16>` **(** **)** |const| |
  112. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  113. | :ref:`String<class_String>` | :ref:`get_string_from_utf32<class_PackedByteArray_method_get_string_from_utf32>` **(** **)** |const| |
  114. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  115. | :ref:`String<class_String>` | :ref:`get_string_from_wchar<class_PackedByteArray_method_get_string_from_wchar>` **(** **)** |const| |
  116. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  117. | :ref:`bool<class_bool>` | :ref:`has<class_PackedByteArray_method_has>` **(** :ref:`int<class_int>` value **)** |const| |
  118. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  119. | :ref:`bool<class_bool>` | :ref:`has_encoded_var<class_PackedByteArray_method_has_encoded_var>` **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const| |
  120. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  121. | :ref:`String<class_String>` | :ref:`hex_encode<class_PackedByteArray_method_hex_encode>` **(** **)** |const| |
  122. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  123. | :ref:`int<class_int>` | :ref:`insert<class_PackedByteArray_method_insert>` **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)** |
  124. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  125. | :ref:`bool<class_bool>` | :ref:`is_empty<class_PackedByteArray_method_is_empty>` **(** **)** |const| |
  126. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  127. | :ref:`bool<class_bool>` | :ref:`push_back<class_PackedByteArray_method_push_back>` **(** :ref:`int<class_int>` value **)** |
  128. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  129. | void | :ref:`remove_at<class_PackedByteArray_method_remove_at>` **(** :ref:`int<class_int>` index **)** |
  130. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  131. | :ref:`int<class_int>` | :ref:`resize<class_PackedByteArray_method_resize>` **(** :ref:`int<class_int>` new_size **)** |
  132. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  133. | void | :ref:`reverse<class_PackedByteArray_method_reverse>` **(** **)** |
  134. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  135. | :ref:`int<class_int>` | :ref:`rfind<class_PackedByteArray_method_rfind>` **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const| |
  136. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  137. | void | :ref:`set<class_PackedByteArray_method_set>` **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)** |
  138. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  139. | :ref:`int<class_int>` | :ref:`size<class_PackedByteArray_method_size>` **(** **)** |const| |
  140. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  141. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`slice<class_PackedByteArray_method_slice>` **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const| |
  142. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  143. | void | :ref:`sort<class_PackedByteArray_method_sort>` **(** **)** |
  144. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  145. | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`to_float32_array<class_PackedByteArray_method_to_float32_array>` **(** **)** |const| |
  146. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  147. | :ref:`PackedFloat64Array<class_PackedFloat64Array>` | :ref:`to_float64_array<class_PackedByteArray_method_to_float64_array>` **(** **)** |const| |
  148. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  149. | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`to_int32_array<class_PackedByteArray_method_to_int32_array>` **(** **)** |const| |
  150. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  151. | :ref:`PackedInt64Array<class_PackedInt64Array>` | :ref:`to_int64_array<class_PackedByteArray_method_to_int64_array>` **(** **)** |const| |
  152. +-----------------------------------------------------+--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
  153. .. rst-class:: classref-reftable-group
  154. Operators
  155. ---------
  156. .. table::
  157. :widths: auto
  158. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  159. | :ref:`bool<class_bool>` | :ref:`operator !=<class_PackedByteArray_operator_neq_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  160. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  161. | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`operator +<class_PackedByteArray_operator_sum_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  162. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  163. | :ref:`bool<class_bool>` | :ref:`operator ==<class_PackedByteArray_operator_eq_PackedByteArray>` **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)** |
  164. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  165. | :ref:`int<class_int>` | :ref:`operator []<class_PackedByteArray_operator_idx_int>` **(** :ref:`int<class_int>` index **)** |
  166. +-----------------------------------------------+----------------------------------------------------------------------------------------------------------------------------------------+
  167. .. rst-class:: classref-section-separator
  168. ----
  169. .. rst-class:: classref-descriptions-group
  170. Constructor Descriptions
  171. ------------------------
  172. .. _class_PackedByteArray_constructor_PackedByteArray:
  173. .. rst-class:: classref-constructor
  174. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** **)**
  175. Constructs an empty **PackedByteArray**.
  176. .. rst-class:: classref-item-separator
  177. ----
  178. .. rst-class:: classref-constructor
  179. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** :ref:`PackedByteArray<class_PackedByteArray>` from **)**
  180. Constructs a **PackedByteArray** as a copy of the given **PackedByteArray**.
  181. .. rst-class:: classref-item-separator
  182. ----
  183. .. rst-class:: classref-constructor
  184. :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray** **(** :ref:`Array<class_Array>` from **)**
  185. Constructs a new **PackedByteArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
  186. .. rst-class:: classref-section-separator
  187. ----
  188. .. rst-class:: classref-descriptions-group
  189. Method Descriptions
  190. -------------------
  191. .. _class_PackedByteArray_method_append:
  192. .. rst-class:: classref-method
  193. :ref:`bool<class_bool>` **append** **(** :ref:`int<class_int>` value **)**
  194. Appends an element at the end of the array (alias of :ref:`push_back<class_PackedByteArray_method_push_back>`).
  195. .. rst-class:: classref-item-separator
  196. ----
  197. .. _class_PackedByteArray_method_append_array:
  198. .. rst-class:: classref-method
  199. void **append_array** **(** :ref:`PackedByteArray<class_PackedByteArray>` array **)**
  200. Appends a **PackedByteArray** at the end of this array.
  201. .. rst-class:: classref-item-separator
  202. ----
  203. .. _class_PackedByteArray_method_bsearch:
  204. .. rst-class:: classref-method
  205. :ref:`int<class_int>` **bsearch** **(** :ref:`int<class_int>` value, :ref:`bool<class_bool>` before=true **)**
  206. 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.
  207. \ **Note:** Calling :ref:`bsearch<class_PackedByteArray_method_bsearch>` on an unsorted array results in unexpected behavior.
  208. .. rst-class:: classref-item-separator
  209. ----
  210. .. _class_PackedByteArray_method_clear:
  211. .. rst-class:: classref-method
  212. void **clear** **(** **)**
  213. Clears the array. This is equivalent to using :ref:`resize<class_PackedByteArray_method_resize>` with a size of ``0``.
  214. .. rst-class:: classref-item-separator
  215. ----
  216. .. _class_PackedByteArray_method_compress:
  217. .. rst-class:: classref-method
  218. :ref:`PackedByteArray<class_PackedByteArray>` **compress** **(** :ref:`int<class_int>` compression_mode=0 **)** |const|
  219. Returns a new **PackedByteArray** with the data compressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
  220. .. rst-class:: classref-item-separator
  221. ----
  222. .. _class_PackedByteArray_method_count:
  223. .. rst-class:: classref-method
  224. :ref:`int<class_int>` **count** **(** :ref:`int<class_int>` value **)** |const|
  225. Returns the number of times an element is in the array.
  226. .. rst-class:: classref-item-separator
  227. ----
  228. .. _class_PackedByteArray_method_decode_double:
  229. .. rst-class:: classref-method
  230. :ref:`float<class_float>` **decode_double** **(** :ref:`int<class_int>` byte_offset **)** |const|
  231. 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.
  232. .. rst-class:: classref-item-separator
  233. ----
  234. .. _class_PackedByteArray_method_decode_float:
  235. .. rst-class:: classref-method
  236. :ref:`float<class_float>` **decode_float** **(** :ref:`int<class_int>` byte_offset **)** |const|
  237. 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.
  238. .. rst-class:: classref-item-separator
  239. ----
  240. .. _class_PackedByteArray_method_decode_half:
  241. .. rst-class:: classref-method
  242. :ref:`float<class_float>` **decode_half** **(** :ref:`int<class_int>` byte_offset **)** |const|
  243. 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.
  244. .. rst-class:: classref-item-separator
  245. ----
  246. .. _class_PackedByteArray_method_decode_s8:
  247. .. rst-class:: classref-method
  248. :ref:`int<class_int>` **decode_s8** **(** :ref:`int<class_int>` byte_offset **)** |const|
  249. 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.
  250. .. rst-class:: classref-item-separator
  251. ----
  252. .. _class_PackedByteArray_method_decode_s16:
  253. .. rst-class:: classref-method
  254. :ref:`int<class_int>` **decode_s16** **(** :ref:`int<class_int>` byte_offset **)** |const|
  255. 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.
  256. .. rst-class:: classref-item-separator
  257. ----
  258. .. _class_PackedByteArray_method_decode_s32:
  259. .. rst-class:: classref-method
  260. :ref:`int<class_int>` **decode_s32** **(** :ref:`int<class_int>` byte_offset **)** |const|
  261. 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.
  262. .. rst-class:: classref-item-separator
  263. ----
  264. .. _class_PackedByteArray_method_decode_s64:
  265. .. rst-class:: classref-method
  266. :ref:`int<class_int>` **decode_s64** **(** :ref:`int<class_int>` byte_offset **)** |const|
  267. 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.
  268. .. rst-class:: classref-item-separator
  269. ----
  270. .. _class_PackedByteArray_method_decode_u8:
  271. .. rst-class:: classref-method
  272. :ref:`int<class_int>` **decode_u8** **(** :ref:`int<class_int>` byte_offset **)** |const|
  273. 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.
  274. .. rst-class:: classref-item-separator
  275. ----
  276. .. _class_PackedByteArray_method_decode_u16:
  277. .. rst-class:: classref-method
  278. :ref:`int<class_int>` **decode_u16** **(** :ref:`int<class_int>` byte_offset **)** |const|
  279. 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.
  280. .. rst-class:: classref-item-separator
  281. ----
  282. .. _class_PackedByteArray_method_decode_u32:
  283. .. rst-class:: classref-method
  284. :ref:`int<class_int>` **decode_u32** **(** :ref:`int<class_int>` byte_offset **)** |const|
  285. 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.
  286. .. rst-class:: classref-item-separator
  287. ----
  288. .. _class_PackedByteArray_method_decode_u64:
  289. .. rst-class:: classref-method
  290. :ref:`int<class_int>` **decode_u64** **(** :ref:`int<class_int>` byte_offset **)** |const|
  291. 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.
  292. .. rst-class:: classref-item-separator
  293. ----
  294. .. _class_PackedByteArray_method_decode_var:
  295. .. rst-class:: classref-method
  296. :ref:`Variant<class_Variant>` **decode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  297. 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``.
  298. .. rst-class:: classref-item-separator
  299. ----
  300. .. _class_PackedByteArray_method_decode_var_size:
  301. .. rst-class:: classref-method
  302. :ref:`int<class_int>` **decode_var_size** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  303. 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.
  304. .. rst-class:: classref-item-separator
  305. ----
  306. .. _class_PackedByteArray_method_decompress:
  307. .. rst-class:: classref-method
  308. :ref:`PackedByteArray<class_PackedByteArray>` **decompress** **(** :ref:`int<class_int>` buffer_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  309. 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.
  310. \ **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.
  311. .. rst-class:: classref-item-separator
  312. ----
  313. .. _class_PackedByteArray_method_decompress_dynamic:
  314. .. rst-class:: classref-method
  315. :ref:`PackedByteArray<class_PackedByteArray>` **decompress_dynamic** **(** :ref:`int<class_int>` max_output_size, :ref:`int<class_int>` compression_mode=0 **)** |const|
  316. 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.**\
  317. 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.
  318. 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.
  319. \ **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.
  320. .. rst-class:: classref-item-separator
  321. ----
  322. .. _class_PackedByteArray_method_duplicate:
  323. .. rst-class:: classref-method
  324. :ref:`PackedByteArray<class_PackedByteArray>` **duplicate** **(** **)**
  325. Creates a copy of the array, and returns it.
  326. .. rst-class:: classref-item-separator
  327. ----
  328. .. _class_PackedByteArray_method_encode_double:
  329. .. rst-class:: classref-method
  330. void **encode_double** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  331. 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.
  332. .. rst-class:: classref-item-separator
  333. ----
  334. .. _class_PackedByteArray_method_encode_float:
  335. .. rst-class:: classref-method
  336. void **encode_float** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  337. 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.
  338. .. rst-class:: classref-item-separator
  339. ----
  340. .. _class_PackedByteArray_method_encode_half:
  341. .. rst-class:: classref-method
  342. void **encode_half** **(** :ref:`int<class_int>` byte_offset, :ref:`float<class_float>` value **)**
  343. 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.
  344. .. rst-class:: classref-item-separator
  345. ----
  346. .. _class_PackedByteArray_method_encode_s8:
  347. .. rst-class:: classref-method
  348. void **encode_s8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  349. 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.
  350. .. rst-class:: classref-item-separator
  351. ----
  352. .. _class_PackedByteArray_method_encode_s16:
  353. .. rst-class:: classref-method
  354. void **encode_s16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  355. 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.
  356. .. rst-class:: classref-item-separator
  357. ----
  358. .. _class_PackedByteArray_method_encode_s32:
  359. .. rst-class:: classref-method
  360. void **encode_s32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  361. 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.
  362. .. rst-class:: classref-item-separator
  363. ----
  364. .. _class_PackedByteArray_method_encode_s64:
  365. .. rst-class:: classref-method
  366. void **encode_s64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  367. 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.
  368. .. rst-class:: classref-item-separator
  369. ----
  370. .. _class_PackedByteArray_method_encode_u8:
  371. .. rst-class:: classref-method
  372. void **encode_u8** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  373. 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.
  374. .. rst-class:: classref-item-separator
  375. ----
  376. .. _class_PackedByteArray_method_encode_u16:
  377. .. rst-class:: classref-method
  378. void **encode_u16** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  379. 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.
  380. .. rst-class:: classref-item-separator
  381. ----
  382. .. _class_PackedByteArray_method_encode_u32:
  383. .. rst-class:: classref-method
  384. void **encode_u32** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  385. 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.
  386. .. rst-class:: classref-item-separator
  387. ----
  388. .. _class_PackedByteArray_method_encode_u64:
  389. .. rst-class:: classref-method
  390. void **encode_u64** **(** :ref:`int<class_int>` byte_offset, :ref:`int<class_int>` value **)**
  391. 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.
  392. .. rst-class:: classref-item-separator
  393. ----
  394. .. _class_PackedByteArray_method_encode_var:
  395. .. rst-class:: classref-method
  396. :ref:`int<class_int>` **encode_var** **(** :ref:`int<class_int>` byte_offset, :ref:`Variant<class_Variant>` value, :ref:`bool<class_bool>` allow_objects=false **)**
  397. 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.
  398. .. rst-class:: classref-item-separator
  399. ----
  400. .. _class_PackedByteArray_method_fill:
  401. .. rst-class:: classref-method
  402. void **fill** **(** :ref:`int<class_int>` value **)**
  403. 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.
  404. .. rst-class:: classref-item-separator
  405. ----
  406. .. _class_PackedByteArray_method_find:
  407. .. rst-class:: classref-method
  408. :ref:`int<class_int>` **find** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=0 **)** |const|
  409. Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
  410. .. rst-class:: classref-item-separator
  411. ----
  412. .. _class_PackedByteArray_method_get_string_from_ascii:
  413. .. rst-class:: classref-method
  414. :ref:`String<class_String>` **get_string_from_ascii** **(** **)** |const|
  415. 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>`.
  416. .. rst-class:: classref-item-separator
  417. ----
  418. .. _class_PackedByteArray_method_get_string_from_utf8:
  419. .. rst-class:: classref-method
  420. :ref:`String<class_String>` **get_string_from_utf8** **(** **)** |const|
  421. 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>`.
  422. .. rst-class:: classref-item-separator
  423. ----
  424. .. _class_PackedByteArray_method_get_string_from_utf16:
  425. .. rst-class:: classref-method
  426. :ref:`String<class_String>` **get_string_from_utf16** **(** **)** |const|
  427. 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>`.
  428. .. rst-class:: classref-item-separator
  429. ----
  430. .. _class_PackedByteArray_method_get_string_from_utf32:
  431. .. rst-class:: classref-method
  432. :ref:`String<class_String>` **get_string_from_utf32** **(** **)** |const|
  433. 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>`.
  434. .. rst-class:: classref-item-separator
  435. ----
  436. .. _class_PackedByteArray_method_get_string_from_wchar:
  437. .. rst-class:: classref-method
  438. :ref:`String<class_String>` **get_string_from_wchar** **(** **)** |const|
  439. 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>`.
  440. .. rst-class:: classref-item-separator
  441. ----
  442. .. _class_PackedByteArray_method_has:
  443. .. rst-class:: classref-method
  444. :ref:`bool<class_bool>` **has** **(** :ref:`int<class_int>` value **)** |const|
  445. Returns ``true`` if the array contains ``value``.
  446. .. rst-class:: classref-item-separator
  447. ----
  448. .. _class_PackedByteArray_method_has_encoded_var:
  449. .. rst-class:: classref-method
  450. :ref:`bool<class_bool>` **has_encoded_var** **(** :ref:`int<class_int>` byte_offset, :ref:`bool<class_bool>` allow_objects=false **)** |const|
  451. 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``.
  452. .. rst-class:: classref-item-separator
  453. ----
  454. .. _class_PackedByteArray_method_hex_encode:
  455. .. rst-class:: classref-method
  456. :ref:`String<class_String>` **hex_encode** **(** **)** |const|
  457. Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
  458. .. tabs::
  459. .. code-tab:: gdscript
  460. var array = PackedByteArray([11, 46, 255])
  461. print(array.hex_encode()) # Prints: 0b2eff
  462. .. code-tab:: csharp
  463. var array = new byte[] {11, 46, 255};
  464. GD.Print(array.HexEncode()); // Prints: 0b2eff
  465. .. rst-class:: classref-item-separator
  466. ----
  467. .. _class_PackedByteArray_method_insert:
  468. .. rst-class:: classref-method
  469. :ref:`int<class_int>` **insert** **(** :ref:`int<class_int>` at_index, :ref:`int<class_int>` value **)**
  470. 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()``).
  471. .. rst-class:: classref-item-separator
  472. ----
  473. .. _class_PackedByteArray_method_is_empty:
  474. .. rst-class:: classref-method
  475. :ref:`bool<class_bool>` **is_empty** **(** **)** |const|
  476. Returns ``true`` if the array is empty.
  477. .. rst-class:: classref-item-separator
  478. ----
  479. .. _class_PackedByteArray_method_push_back:
  480. .. rst-class:: classref-method
  481. :ref:`bool<class_bool>` **push_back** **(** :ref:`int<class_int>` value **)**
  482. Appends an element at the end of the array.
  483. .. rst-class:: classref-item-separator
  484. ----
  485. .. _class_PackedByteArray_method_remove_at:
  486. .. rst-class:: classref-method
  487. void **remove_at** **(** :ref:`int<class_int>` index **)**
  488. Removes an element from the array by index.
  489. .. rst-class:: classref-item-separator
  490. ----
  491. .. _class_PackedByteArray_method_resize:
  492. .. rst-class:: classref-method
  493. :ref:`int<class_int>` **resize** **(** :ref:`int<class_int>` new_size **)**
  494. 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.
  495. .. rst-class:: classref-item-separator
  496. ----
  497. .. _class_PackedByteArray_method_reverse:
  498. .. rst-class:: classref-method
  499. void **reverse** **(** **)**
  500. Reverses the order of the elements in the array.
  501. .. rst-class:: classref-item-separator
  502. ----
  503. .. _class_PackedByteArray_method_rfind:
  504. .. rst-class:: classref-method
  505. :ref:`int<class_int>` **rfind** **(** :ref:`int<class_int>` value, :ref:`int<class_int>` from=-1 **)** |const|
  506. 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.
  507. .. rst-class:: classref-item-separator
  508. ----
  509. .. _class_PackedByteArray_method_set:
  510. .. rst-class:: classref-method
  511. void **set** **(** :ref:`int<class_int>` index, :ref:`int<class_int>` value **)**
  512. Changes the byte at the given index.
  513. .. rst-class:: classref-item-separator
  514. ----
  515. .. _class_PackedByteArray_method_size:
  516. .. rst-class:: classref-method
  517. :ref:`int<class_int>` **size** **(** **)** |const|
  518. Returns the number of elements in the array.
  519. .. rst-class:: classref-item-separator
  520. ----
  521. .. _class_PackedByteArray_method_slice:
  522. .. rst-class:: classref-method
  523. :ref:`PackedByteArray<class_PackedByteArray>` **slice** **(** :ref:`int<class_int>` begin, :ref:`int<class_int>` end=2147483647 **)** |const|
  524. Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
  525. 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())``).
  526. 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)``).
  527. .. rst-class:: classref-item-separator
  528. ----
  529. .. _class_PackedByteArray_method_sort:
  530. .. rst-class:: classref-method
  531. void **sort** **(** **)**
  532. Sorts the elements of the array in ascending order.
  533. .. rst-class:: classref-item-separator
  534. ----
  535. .. _class_PackedByteArray_method_to_float32_array:
  536. .. rst-class:: classref-method
  537. :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array** **(** **)** |const|
  538. 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``).
  539. 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``.
  540. If the original data can't be converted to 32-bit floats, the resulting data is undefined.
  541. .. rst-class:: classref-item-separator
  542. ----
  543. .. _class_PackedByteArray_method_to_float64_array:
  544. .. rst-class:: classref-method
  545. :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array** **(** **)** |const|
  546. 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>`).
  547. 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``.
  548. If the original data can't be converted to 64-bit floats, the resulting data is undefined.
  549. .. rst-class:: classref-item-separator
  550. ----
  551. .. _class_PackedByteArray_method_to_int32_array:
  552. .. rst-class:: classref-method
  553. :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array** **(** **)** |const|
  554. 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``).
  555. 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``.
  556. If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
  557. .. rst-class:: classref-item-separator
  558. ----
  559. .. _class_PackedByteArray_method_to_int64_array:
  560. .. rst-class:: classref-method
  561. :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array** **(** **)** |const|
  562. 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>`).
  563. 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``.
  564. If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
  565. .. rst-class:: classref-section-separator
  566. ----
  567. .. rst-class:: classref-descriptions-group
  568. Operator Descriptions
  569. ---------------------
  570. .. _class_PackedByteArray_operator_neq_PackedByteArray:
  571. .. rst-class:: classref-operator
  572. :ref:`bool<class_bool>` **operator !=** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  573. Returns ``true`` if contents of the arrays differ.
  574. .. rst-class:: classref-item-separator
  575. ----
  576. .. _class_PackedByteArray_operator_sum_PackedByteArray:
  577. .. rst-class:: classref-operator
  578. :ref:`PackedByteArray<class_PackedByteArray>` **operator +** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  579. 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.
  580. .. rst-class:: classref-item-separator
  581. ----
  582. .. _class_PackedByteArray_operator_eq_PackedByteArray:
  583. .. rst-class:: classref-operator
  584. :ref:`bool<class_bool>` **operator ==** **(** :ref:`PackedByteArray<class_PackedByteArray>` right **)**
  585. Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
  586. .. rst-class:: classref-item-separator
  587. ----
  588. .. _class_PackedByteArray_operator_idx_int:
  589. .. rst-class:: classref-operator
  590. :ref:`int<class_int>` **operator []** **(** :ref:`int<class_int>` index **)**
  591. 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.
  592. Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
  593. .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
  594. .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
  595. .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
  596. .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
  597. .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
  598. .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
  599. .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`