Attention | Topic was automatically imported from the old Question2Answer platform. | |
Asked By | Wabbitseason | |
Old Version | Published before Godot 3 was released. |
I’m trying to write and read large Dictionaries to files. It looks to me a simple file.get_var()
blocks the thread, so I cannot update the UI (to show a progress bar).
If I’m writing the Dictionary to a file as a JSON string, I can read back the data by lines: I enable the _process
method, read a couple of lines, concatenate them into a string buffer, then exit the _process method and at its end I update the progress bar. On the next occasion I read a couple of lines again, and this keeps on repeating until I’ve read all the remaining lines from the file, then I disable the _process method, and finally parse the complete string as JSON.
This approach is fine, but instead of the JSON format I’d like to use binary serialization. However, I don’t understand how I could use the get_var()
function in this case (by building for example an array of bytes via looped file.get_32()
calls in a _process
loop, periodially updating the progress bar and finally feeding that array of bytes into get_var
). The “Binary serialization API” doc mentions that the PacketPeer
class also implements the get_var
method, but I can’t figure out how I could actually use it.
Could someone show me an example?
Hm, maybe bytes2var
?
Wabbitseason | 2018-01-20 14:09