Attention: Here be dragons
This is the latest
(unstable) version of this documentation, which may document features
not available in or compatible with released stable versions of Godot.
Checking the stable version of the documentation...
PCKPacker¶
继承: RefCounted < Object
创建可以加载到正在运行的项目中的包。
描述¶
PCKPacker 可以创建打包文件,项目运行时可以使用 ProjectSettings.load_resource_pack 来加载打包文件。
var packer = PCKPacker.new()
packer.pck_start("test.pck")
packer.add_file("res://text.txt", "text.txt")
packer.flush()
var packer = new PckPacker();
packer.PckStart("test.pck");
packer.AddFile("res://text.txt", "text.txt");
packer.Flush();
上面的例子中,PCKPacker 创建了打包文件 test.pck,但后将名为 text.txt 的文件添加到了包的根目录。
方法¶
add_file(pck_path: String, source_path: String, encrypt: bool = false) |
|
pck_start(pck_name: String, alignment: int = 32, key: String = "0000000000000000000000000000000000000000000000000000000000000000", encrypt_directory: bool = false) |
方法说明¶
Error add_file(pck_path: String, source_path: String, encrypt: bool = false) 🔗
将 source_path 文件添加到当前 PCK 包的内部路径 pck_path 中(应以 res:// 开头)。
Error flush(verbose: bool = false) 🔗
自上次刷新以来,使用所有 add_file 调用写入指定的文件。如果 verbose 为 true,被添加的文件的列表将被打印到控制台,以便于调试。
Error pck_start(pck_name: String, alignment: int = 32, key: String = "0000000000000000000000000000000000000000000000000000000000000000", encrypt_directory: bool = false) 🔗
创建一个名为 pck_name 的新 PCK 文件。不会自动添加 .pck 文件扩展名,因此它应该是 pck_name 的一部分(即使它不是必需的)。