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.

PCKPacker

Eredita: RefCounted < Object

Crea pacchetti che possono essere caricati in un progetto in esecuzione.

Descrizione

PCKPacker serve per creare pacchetti che è possibile caricare in un progetto in esecuzione attraverso ProjectSettings.load_resource_pack().

var packer = PCKPacker.new()
packer.pck_start("test.pck")
packer.add_file("res://text.txt", "text.txt")
packer.flush()

Il PCKPacker soprastante crea il pacchetto test.pck, quindi aggiunge un file denominato text.txt alla radice del pacchetto.

Nota: PCK è il formato di file impacchettato di Godot. Per creare archivi ZIP che è possibile leggere da qualsiasi programma, usa invece ZIPPacker.

Metodi

Error

add_file(target_path: String, source_path: String, encrypt: bool = false)

Error

add_file_from_buffer(target_path: String, data: PackedByteArray, encrypt: bool = false)

Error

add_file_removal(target_path: String)

Error

flush(verbose: bool = false)

Error

pck_start(pck_path: String, alignment: int = 32, key: String = "0000000000000000000000000000000000000000000000000000000000000000", encrypt_directory: bool = false)


Descrizioni dei metodi

Error add_file(target_path: String, source_path: String, encrypt: bool = false) 🔗

Aggiunge il file nel percorso source_path al pacchetto PCK attuale nel percorso interno target_path. Il prefisso res:// per target_path è facoltativo e rimosso internamente. Il contenuto del file viene scritto immediatamente sul PCK.


Error add_file_from_buffer(target_path: String, data: PackedByteArray, encrypt: bool = false) 🔗

Adds the data to the current PCK package at the target_path internal path. The res:// prefix for target_path is optional and stripped internally. File content is immediately written to the PCK.


Error add_file_removal(target_path: String) 🔗

Registra una rimozione di file del percorso interno target_path al PCK. Questo è usato principalmente per le patch. Se il file in questo percorso è stato caricato da un PCK precedente, verrà rimosso. Il prefisso res:// per target_path è facoltativo e rimosso internamente.


Error flush(verbose: bool = false) 🔗

Scrive la cartella dei file e chiude il PCK. Se verbose è true, sarà visualizzato un elenco dei file aggiunti sulla console per facilitare il debug.

Nota: FileAccess si chiuderà automaticamente quando viene liberato, il che accade quando esce dall'ambito o quando gli viene assegnato null. In C# il riferimento deve essere eliminato manualmente, il che può essere fatto con l'istruzione using o chiamando direttamente il metodo Dispose.


Error pck_start(pck_path: String, alignment: int = 32, key: String = "0000000000000000000000000000000000000000000000000000000000000000", encrypt_directory: bool = false) 🔗

Crea un nuovo file PCK con al percorso pck_path. L'estensione del file .pck non viene aggiunta automaticamente, quindi dovrebbe far parte di pck_path (anche se non è obbligatoria).