12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064 |
- :github_url: hide
- .. DO NOT EDIT THIS FILE!!!
- .. Generated automatically from Godot engine sources.
- .. Generator: https://github.com/godotengine/godot/tree/master/doc/tools/make_rst.py.
- .. XML source: https://github.com/godotengine/godot/tree/master/doc/classes/PackedByteArray.xml.
- .. _class_PackedByteArray:
- PackedByteArray
- ===============
- A packed array of bytes.
- .. rst-class:: classref-introduction-group
- Description
- -----------
- An array specifically designed to hold bytes. Packs data tightly, so it saves memory for large array sizes.
- \ **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.
- \ **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.
- .. note::
- There are notable differences when using this API with C#. See :ref:`doc_c_sharp_differences` for more information.
- .. rst-class:: classref-reftable-group
- Constructors
- ------------
- .. table::
- :widths: auto
- +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ ) |
- +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ from\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
- +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`PackedByteArray<class_PackedByteArray_constructor_PackedByteArray>`\ (\ from\: :ref:`Array<class_Array>`\ ) |
- +-----------------------------------------------+---------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Methods
- -------
- .. table::
- :widths: auto
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`append<class_PackedByteArray_method_append>`\ (\ value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`append_array<class_PackedByteArray_method_append_array>`\ (\ array\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`bsearch<class_PackedByteArray_method_bsearch>`\ (\ value\: :ref:`int<class_int>`, before\: :ref:`bool<class_bool>` = true\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`clear<class_PackedByteArray_method_clear>`\ (\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`compress<class_PackedByteArray_method_compress>`\ (\ compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`count<class_PackedByteArray_method_count>`\ (\ value\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`decode_double<class_PackedByteArray_method_decode_double>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`decode_float<class_PackedByteArray_method_decode_float>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`float<class_float>` | :ref:`decode_half<class_PackedByteArray_method_decode_half>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_s8<class_PackedByteArray_method_decode_s8>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_s16<class_PackedByteArray_method_decode_s16>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_s32<class_PackedByteArray_method_decode_s32>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_s64<class_PackedByteArray_method_decode_s64>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_u8<class_PackedByteArray_method_decode_u8>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_u16<class_PackedByteArray_method_decode_u16>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_u32<class_PackedByteArray_method_decode_u32>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`decode_u64<class_PackedByteArray_method_decode_u64>`\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :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| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :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| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`decompress<class_PackedByteArray_method_decompress>`\ (\ buffer_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :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| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`duplicate<class_PackedByteArray_method_duplicate>`\ (\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_double<class_PackedByteArray_method_encode_double>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_float<class_PackedByteArray_method_encode_float>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_half<class_PackedByteArray_method_encode_half>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_s8<class_PackedByteArray_method_encode_s8>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_s16<class_PackedByteArray_method_encode_s16>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_s32<class_PackedByteArray_method_encode_s32>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_s64<class_PackedByteArray_method_encode_s64>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_u8<class_PackedByteArray_method_encode_u8>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_u16<class_PackedByteArray_method_encode_u16>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_u32<class_PackedByteArray_method_encode_u32>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`encode_u64<class_PackedByteArray_method_encode_u64>`\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :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\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`fill<class_PackedByteArray_method_fill>`\ (\ value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`find<class_PackedByteArray_method_find>`\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = 0\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`get<class_PackedByteArray_method_get>`\ (\ index\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_string_from_ascii<class_PackedByteArray_method_get_string_from_ascii>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_string_from_utf8<class_PackedByteArray_method_get_string_from_utf8>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_string_from_utf16<class_PackedByteArray_method_get_string_from_utf16>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_string_from_utf32<class_PackedByteArray_method_get_string_from_utf32>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`get_string_from_wchar<class_PackedByteArray_method_get_string_from_wchar>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`has<class_PackedByteArray_method_has>`\ (\ value\: :ref:`int<class_int>`\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :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| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`String<class_String>` | :ref:`hex_encode<class_PackedByteArray_method_hex_encode>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`insert<class_PackedByteArray_method_insert>`\ (\ at_index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`is_empty<class_PackedByteArray_method_is_empty>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`push_back<class_PackedByteArray_method_push_back>`\ (\ value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`remove_at<class_PackedByteArray_method_remove_at>`\ (\ index\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`resize<class_PackedByteArray_method_resize>`\ (\ new_size\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`reverse<class_PackedByteArray_method_reverse>`\ (\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`rfind<class_PackedByteArray_method_rfind>`\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = -1\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`set<class_PackedByteArray_method_set>`\ (\ index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`size<class_PackedByteArray_method_size>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`slice<class_PackedByteArray_method_slice>`\ (\ begin\: :ref:`int<class_int>`, end\: :ref:`int<class_int>` = 2147483647\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | |void| | :ref:`sort<class_PackedByteArray_method_sort>`\ (\ ) |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedFloat32Array<class_PackedFloat32Array>` | :ref:`to_float32_array<class_PackedByteArray_method_to_float32_array>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedFloat64Array<class_PackedFloat64Array>` | :ref:`to_float64_array<class_PackedByteArray_method_to_float64_array>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedInt32Array<class_PackedInt32Array>` | :ref:`to_int32_array<class_PackedByteArray_method_to_int32_array>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedInt64Array<class_PackedInt64Array>` | :ref:`to_int64_array<class_PackedByteArray_method_to_int64_array>`\ (\ ) |const| |
- +-----------------------------------------------------+-----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-reftable-group
- Operators
- ---------
- .. table::
- :widths: auto
- +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator !=<class_PackedByteArray_operator_neq_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
- +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`PackedByteArray<class_PackedByteArray>` | :ref:`operator +<class_PackedByteArray_operator_sum_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
- +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`bool<class_bool>` | :ref:`operator ==<class_PackedByteArray_operator_eq_PackedByteArray>`\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) |
- +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
- | :ref:`int<class_int>` | :ref:`operator []<class_PackedByteArray_operator_idx_int>`\ (\ index\: :ref:`int<class_int>`\ ) |
- +-----------------------------------------------+-------------------------------------------------------------------------------------------------------------------------------------+
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Constructor Descriptions
- ------------------------
- .. _class_PackedByteArray_constructor_PackedByteArray:
- .. rst-class:: classref-constructor
- :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ ) :ref:`๐<class_PackedByteArray_constructor_PackedByteArray>`
- Constructs an empty **PackedByteArray**.
- .. rst-class:: classref-item-separator
- ----
- .. rst-class:: classref-constructor
- :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ from\: :ref:`PackedByteArray<class_PackedByteArray>`\ )
- Constructs a **PackedByteArray** as a copy of the given **PackedByteArray**.
- .. rst-class:: classref-item-separator
- ----
- .. rst-class:: classref-constructor
- :ref:`PackedByteArray<class_PackedByteArray>` **PackedByteArray**\ (\ from\: :ref:`Array<class_Array>`\ )
- Constructs a new **PackedByteArray**. Optionally, you can pass in a generic :ref:`Array<class_Array>` that will be converted.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Method Descriptions
- -------------------
- .. _class_PackedByteArray_method_append:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **append**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_append>`
- Appends an element at the end of the array (alias of :ref:`push_back<class_PackedByteArray_method_push_back>`).
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_append_array:
- .. rst-class:: classref-method
- |void| **append_array**\ (\ array\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐<class_PackedByteArray_method_append_array>`
- Appends a **PackedByteArray** at the end of this array.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_bsearch:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **bsearch**\ (\ value\: :ref:`int<class_int>`, before\: :ref:`bool<class_bool>` = true\ ) :ref:`๐<class_PackedByteArray_method_bsearch>`
- 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.
- \ **Note:** Calling :ref:`bsearch<class_PackedByteArray_method_bsearch>` on an unsorted array results in unexpected behavior.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_clear:
- .. rst-class:: classref-method
- |void| **clear**\ (\ ) :ref:`๐<class_PackedByteArray_method_clear>`
- Clears the array. This is equivalent to using :ref:`resize<class_PackedByteArray_method_resize>` with a size of ``0``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_compress:
- .. rst-class:: classref-method
- :ref:`PackedByteArray<class_PackedByteArray>` **compress**\ (\ compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`๐<class_PackedByteArray_method_compress>`
- Returns a new **PackedByteArray** with the data compressed. Set the compression mode using one of :ref:`CompressionMode<enum_FileAccess_CompressionMode>`'s constants.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_count:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **count**\ (\ value\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_count>`
- Returns the number of times an element is in the array.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_double:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **decode_double**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_double>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_float:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **decode_float**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_float>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_half:
- .. rst-class:: classref-method
- :ref:`float<class_float>` **decode_half**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_half>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_s8:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_s8**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_s8>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_s16:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_s16**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_s16>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_s32:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_s32**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_s32>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_s64:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_s64**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_s64>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_u8:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_u8**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_u8>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_u16:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_u16**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_u16>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_u32:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_u32**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_u32>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_u64:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **decode_u64**\ (\ byte_offset\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_decode_u64>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_var:
- .. rst-class:: classref-method
- :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>`
- 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``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decode_var_size:
- .. rst-class:: classref-method
- :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>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decompress:
- .. rst-class:: classref-method
- :ref:`PackedByteArray<class_PackedByteArray>` **decompress**\ (\ buffer_size\: :ref:`int<class_int>`, compression_mode\: :ref:`int<class_int>` = 0\ ) |const| :ref:`๐<class_PackedByteArray_method_decompress>`
- 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.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_decompress_dynamic:
- .. rst-class:: classref-method
- :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>`
- 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.**\
- 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.
- 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.
- \ **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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_duplicate:
- .. rst-class:: classref-method
- :ref:`PackedByteArray<class_PackedByteArray>` **duplicate**\ (\ ) :ref:`๐<class_PackedByteArray_method_duplicate>`
- Creates a copy of the array, and returns it.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_double:
- .. rst-class:: classref-method
- |void| **encode_double**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`๐<class_PackedByteArray_method_encode_double>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_float:
- .. rst-class:: classref-method
- |void| **encode_float**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`๐<class_PackedByteArray_method_encode_float>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_half:
- .. rst-class:: classref-method
- |void| **encode_half**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`float<class_float>`\ ) :ref:`๐<class_PackedByteArray_method_encode_half>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_s8:
- .. rst-class:: classref-method
- |void| **encode_s8**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_s8>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_s16:
- .. rst-class:: classref-method
- |void| **encode_s16**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_s16>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_s32:
- .. rst-class:: classref-method
- |void| **encode_s32**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_s32>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_s64:
- .. rst-class:: classref-method
- |void| **encode_s64**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_s64>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_u8:
- .. rst-class:: classref-method
- |void| **encode_u8**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_u8>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_u16:
- .. rst-class:: classref-method
- |void| **encode_u16**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_u16>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_u32:
- .. rst-class:: classref-method
- |void| **encode_u32**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_u32>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_u64:
- .. rst-class:: classref-method
- |void| **encode_u64**\ (\ byte_offset\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_encode_u64>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_encode_var:
- .. rst-class:: classref-method
- :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>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_fill:
- .. rst-class:: classref-method
- |void| **fill**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_fill>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_find:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **find**\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = 0\ ) |const| :ref:`๐<class_PackedByteArray_method_find>`
- Searches the array for a value and returns its index or ``-1`` if not found. Optionally, the initial search index can be passed.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_get:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **get**\ (\ index\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_get>`
- Returns the byte at the given ``index`` in the array. This is the same as using the ``[]`` operator (``array[index]``).
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_get_string_from_ascii:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_string_from_ascii**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_get_string_from_ascii>`
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_get_string_from_utf8:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_string_from_utf8**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_get_string_from_utf8>`
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_get_string_from_utf16:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_string_from_utf16**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_get_string_from_utf16>`
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_get_string_from_utf32:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_string_from_utf32**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_get_string_from_utf32>`
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_get_string_from_wchar:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **get_string_from_wchar**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_get_string_from_wchar>`
- 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>`.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_has:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **has**\ (\ value\: :ref:`int<class_int>`\ ) |const| :ref:`๐<class_PackedByteArray_method_has>`
- Returns ``true`` if the array contains ``value``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_has_encoded_var:
- .. rst-class:: classref-method
- :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>`
- 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``.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_hex_encode:
- .. rst-class:: classref-method
- :ref:`String<class_String>` **hex_encode**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_hex_encode>`
- Returns a hexadecimal representation of this array as a :ref:`String<class_String>`.
- .. tabs::
- .. code-tab:: gdscript
- var array = PackedByteArray([11, 46, 255])
- print(array.hex_encode()) # Prints: 0b2eff
- .. code-tab:: csharp
- var array = new byte[] {11, 46, 255};
- GD.Print(array.HexEncode()); // Prints: 0b2eff
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_insert:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **insert**\ (\ at_index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_insert>`
- 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()``).
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_is_empty:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **is_empty**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_is_empty>`
- Returns ``true`` if the array is empty.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_push_back:
- .. rst-class:: classref-method
- :ref:`bool<class_bool>` **push_back**\ (\ value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_push_back>`
- Appends an element at the end of the array.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_remove_at:
- .. rst-class:: classref-method
- |void| **remove_at**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_remove_at>`
- Removes an element from the array by index.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_resize:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **resize**\ (\ new_size\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_resize>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_reverse:
- .. rst-class:: classref-method
- |void| **reverse**\ (\ ) :ref:`๐<class_PackedByteArray_method_reverse>`
- Reverses the order of the elements in the array.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_rfind:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **rfind**\ (\ value\: :ref:`int<class_int>`, from\: :ref:`int<class_int>` = -1\ ) |const| :ref:`๐<class_PackedByteArray_method_rfind>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_set:
- .. rst-class:: classref-method
- |void| **set**\ (\ index\: :ref:`int<class_int>`, value\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_method_set>`
- Changes the byte at the given index.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_size:
- .. rst-class:: classref-method
- :ref:`int<class_int>` **size**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_size>`
- Returns the number of elements in the array.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_slice:
- .. rst-class:: classref-method
- :ref:`PackedByteArray<class_PackedByteArray>` **slice**\ (\ begin\: :ref:`int<class_int>`, end\: :ref:`int<class_int>` = 2147483647\ ) |const| :ref:`๐<class_PackedByteArray_method_slice>`
- Returns the slice of the **PackedByteArray**, from ``begin`` (inclusive) to ``end`` (exclusive), as a new **PackedByteArray**.
- 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())``).
- 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)``).
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_sort:
- .. rst-class:: classref-method
- |void| **sort**\ (\ ) :ref:`๐<class_PackedByteArray_method_sort>`
- Sorts the elements of the array in ascending order.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_to_float32_array:
- .. rst-class:: classref-method
- :ref:`PackedFloat32Array<class_PackedFloat32Array>` **to_float32_array**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_to_float32_array>`
- 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``).
- 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``.
- If the original data can't be converted to 32-bit floats, the resulting data is undefined.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_to_float64_array:
- .. rst-class:: classref-method
- :ref:`PackedFloat64Array<class_PackedFloat64Array>` **to_float64_array**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_to_float64_array>`
- 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>`).
- 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``.
- If the original data can't be converted to 64-bit floats, the resulting data is undefined.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_to_int32_array:
- .. rst-class:: classref-method
- :ref:`PackedInt32Array<class_PackedInt32Array>` **to_int32_array**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_to_int32_array>`
- 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``).
- 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``.
- If the original data can't be converted to signed 32-bit integers, the resulting data is undefined.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_method_to_int64_array:
- .. rst-class:: classref-method
- :ref:`PackedInt64Array<class_PackedInt64Array>` **to_int64_array**\ (\ ) |const| :ref:`๐<class_PackedByteArray_method_to_int64_array>`
- 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>`).
- 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``.
- If the original data can't be converted to signed 64-bit integers, the resulting data is undefined.
- .. rst-class:: classref-section-separator
- ----
- .. rst-class:: classref-descriptions-group
- Operator Descriptions
- ---------------------
- .. _class_PackedByteArray_operator_neq_PackedByteArray:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator !=**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐<class_PackedByteArray_operator_neq_PackedByteArray>`
- Returns ``true`` if contents of the arrays differ.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_operator_sum_PackedByteArray:
- .. rst-class:: classref-operator
- :ref:`PackedByteArray<class_PackedByteArray>` **operator +**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐<class_PackedByteArray_operator_sum_PackedByteArray>`
- 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.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_operator_eq_PackedByteArray:
- .. rst-class:: classref-operator
- :ref:`bool<class_bool>` **operator ==**\ (\ right\: :ref:`PackedByteArray<class_PackedByteArray>`\ ) :ref:`๐<class_PackedByteArray_operator_eq_PackedByteArray>`
- Returns ``true`` if contents of both arrays are the same, i.e. they have all equal bytes at the corresponding indices.
- .. rst-class:: classref-item-separator
- ----
- .. _class_PackedByteArray_operator_idx_int:
- .. rst-class:: classref-operator
- :ref:`int<class_int>` **operator []**\ (\ index\: :ref:`int<class_int>`\ ) :ref:`๐<class_PackedByteArray_operator_idx_int>`
- 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.
- Note that the byte is returned as a 64-bit :ref:`int<class_int>`.
- .. |virtual| replace:: :abbr:`virtual (This method should typically be overridden by the user to have any effect.)`
- .. |const| replace:: :abbr:`const (This method has no side effects. It doesn't modify any of the instance's member variables.)`
- .. |vararg| replace:: :abbr:`vararg (This method accepts any number of arguments after the ones described here.)`
- .. |constructor| replace:: :abbr:`constructor (This method is used to construct a type.)`
- .. |static| replace:: :abbr:`static (This method doesn't need an instance to be called, so it can be called directly using the class name.)`
- .. |operator| replace:: :abbr:`operator (This method describes a valid operator to use with this type as left-hand operand.)`
- .. |bitfield| replace:: :abbr:`BitField (This value is an integer composed as a bitmask of the following flags.)`
- .. |void| replace:: :abbr:`void (No return value.)`
|