1
\$\begingroup\$

I'm wondering if it is possible to obtain the filesize of a game's build at runtime.

Searching this topic only yields results for reducing the build size, which is not at all what I'm looking for.

\$\endgroup\$
  • 1
    \$\begingroup\$ Can you clarify what you need this for? This is a somewhat unusual thing to query, which makes me wonder if there might be a more efficient route to solving the core issue or implementing the feature you ultimately want to support. \$\endgroup\$ – DMGregory Jan 7 at 22:33
  • \$\begingroup\$ I haven't had time to test this but you can get the size of your build directory using code from this example link. I'm not sure how helpful this will be since you need to build first and then run your build for it to work. If you want to calculate the size of a potential build in the editor, I think you will just have to guess based on all the assets in your proj \$\endgroup\$ – Benjamin Danger Johnson Jan 8 at 3:42
  • \$\begingroup\$ Isn't this the equivalent of asking for the (recursive) size of directory? That would depend on the OS you're developing on, not the OS you're targeting. And I'm not sure if that question is suited to this particular stack exchange. \$\endgroup\$ – Pikalek Jan 8 at 3:43
0
\$\begingroup\$

If you are using a Mac:

After it's built by Xcode, in the "Unity Player/build" directory there will be the app. In Finder use Get Info to see the size.

Or in Xcode, find the Products group and within that .app item and do Reveal in Finder, then Get Info.

If you want to know the size for the App Store, ZIP compress the app first.

If you are using Windows:

Right click the Unity build you have just created and right click it. Then, click properties, then general, and check the size field.

I hope this is answers your question.

\$\endgroup\$
  • \$\begingroup\$ Note that the question says they want to do this "at runtime" - meaning a script inside the project is running and querying the size of the game it's running in, while a player is playing the game on their device. Based on that, I don't thing a manual process done by the developer before publishing is the kind of solution they're looking for. \$\endgroup\$ – DMGregory Jan 13 at 5:28
  • \$\begingroup\$ @DMGregory Ok, my bad. \$\endgroup\$ – noobprogrammer Jan 13 at 14:26

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.