How to get size of Resource when using ResourceLoader

Godot Version

4.2.1

Question

Hello, I decided to change my project from Godot 3.5 to 4.2. I have there resource loading and its made completly differently than in 3.5, which is fine…I changed the code and my current result is that I get several resources loading which currently is solved as each resource have same weight since I cant find how to get size of resource I go load in 4.2 now…

The question is, is there a way to get how many nodes/file size or something that can differentiate between each resource getting loaded…I mean like build-in property or function “easily” used?..

what is your use case for this kind of information ? is it to display a progress bar during loading ?

Yes. I want to have “optimal” progress bar that counts with 1 or more resources in question(so the difference is shown at 2+ resources)…I mean I want weighted % part for each resource ending at 100%…smaller resource will add 0-10%, bigger 0-25% etc…depending on size or something

[This is not works. And i’m sorry for i have not seen the whole question]

Use ResourceLoader.load_threaded_get_status and pass a array in second argument.
Then it will store a progress to the array.

That works only if there is one resource…

With multiple resources you must give weight for each resource to “divide” the 100% bar into sections…

Example: you have 3 resources. Simple way to divide it, is make each resource same weight so first one loads 0-33%, 2nd one 34-67% and last one 67-100%…thats how I have it now…

But not each resource have same size and will need less of the loading bar or more depending on size…

Lets say: 1st have size 10, 2nd 15, 3rd 25…total size 50…meaning that 1st should do 0-20% of progress, 2nd 20-50% and 3rd 50-100%…

But in godot 3.5.2 I could get size of each resource and make the weights uneven like that, but in Godot 4 its made differently…And except getting file_size guess there is no other way…finding out how many times “load_threaded_status” function will be called(before the actual loading starts)…

try FileAccess.get_length()

Well that will work, but I would have prefered method that doesnt require “opening file”…looked if there is not something like that, but found on some forum proposal and it seems it will be implemented, but is not yet…

This topic was automatically closed 30 days after the last reply. New replies are no longer allowed.