How do I retrieve/deserialize data from a PackedDataContainer?

Godot Version

4.2 Stable


I have a large (size of 10,000) constant Dictionary of Vector2i:int that I am using as a lookup table (the int is an Enum value).

However, having such a large Dictonary loaded in the editor was causing my editor to lag considerably and become unresponsive, so I am trying to serialize/store this constant dictionary into some sort of file and initialize the constant while scripts are being parsed. I found the PackedDataContainer, which claims to be just for effectively storing Arrays and Dictionaries, but there is 0 information I can find on how to retrieve the data once it’s packed.

This Dictionary is programmatically generated from within a tool Scene meant to run while debugging (does NOT use @tool annotation tho. It’s a tool as in it generates this resource for me at debug runtime).


1 Like

It is literally in the docs:

1 Like

I already tried that. That doesn’t work for me in the latest version.

It counts up to 10,000 keys which is right, but I cant seem to do much with those keys.

So it works when the keys are strings, but not when they are Vector2i…

1 Like

Yeah, the documentation states that this only works for string/stringnames. It might be kind of ugly but you could convert your Vector2i to a string.