Up to date

This page is up to date for Godot 4.2. If you still find outdated information, please open an issue.

PackedDataContainerRef

继承: RefCounted < Object

PackedDataContainer 使用的内部类,用于打包嵌套的数组和字典。

描述

使用 PackedDataContainer 打包嵌套容器时,会将其递归打包进 PackedDataContainerRef(仅适用于 ArrayDictionary)。获取数据的方法和 PackedDataContainer 相同。

var packed = PackedDataContainer.new()
packed.pack([1, 2, 3, ["abc", "def"], 4, 5, 6])

for element in packed:
    if element is PackedDataContainerRef:
        for subelement in element:
            print("::", subelement)
    else:
        print(element)

# 输出:
# 1
# 2
# 3
# ::abc
# ::def
# 4
# 5
# 6

方法

int

size ( ) const


方法说明

int size ( ) const

返回打包后容器的大小(见 Array.sizeDictionary.size)。