Referência de funções
Godot 4 · GDScript · Downloadable content
sync_content_keys
Delta-syncs an explicit set of content keys (any category, e.g. on-demand).
Asynchronous (result via signal)
Signature
sync_content_keys(keys: PackedStringArray) -> voidWhat it does
Same pipeline as sync_always_download (cache check, per-key version compare, encrypted on-device storage, per-key content_loaded, then content_sync_complete); only the selection rule differs: an item is synced if and only if its key is in keys. This is the on-demand path: a master index can declare which keys exist so the catalog grows indefinitely with no app update. Idempotent: no-ops while another sync is in flight.
Parameters
| Name | Type | Default | Description |
|---|---|---|---|
| keys | PackedStringArray | required | The exact content keys to sync, regardless of their panel category. An empty set is a no-op that still emits content_sync_complete([], []) so callers never hang. |
How to call it
Connect content_loaded and content_sync_complete first, then call sync_content_keys() with a PackedStringArray of keys.
Result signal: content_sync_complete(updated_keys: Array, cached_keys: Array)
Example
Gamdato.content_loaded.connect(_on_content)
Gamdato.content_sync_complete.connect(_on_done)
Gamdato.sync_content_keys(PackedStringArray(["levels6", "styles_pack_3"]))
func _on_content(key: String, data: Variant) -> void:
_store(key, data[key]) # data is the envelope; your value lives at data[key]
func _on_done(updated: Array, cached: Array) -> void:
print("synced %d keys" % (updated.size() + cached.size()))Use cases
- Sync a specific batch of on-demand packs chosen from a master content index.
- Refresh just the keys a player unlocked, leaving the rest untouched.