Custom or Bundle Resources - what's the difference?

I’m trying to get to grips with these concepts but struggling to get a good picture from the docs alone.

Surface overview in Project settings: https://defold.com/manuals/project-settings/#custom-resources
Some explanation of Custom Resources: https://defold.com/manuals/resource/

What is the difference between Custom and Bundled Resources? When do I use one instead of the other? What are the pros and cons?

Thanks!

Bundle (put next to the bundle) resources get included next to the binary of your game. They are useful when you want something included with your project but also easy to edit. An example of a custom resource which you could use is putting your game’s localization files there instead of inside of the bundle, that way, assuming you have the glyphs enabled, anyone can translate your game. Another example of something you would want to include as a custom resource are FMOD audio banks, including them in bundle resources makes them take up more memory and be less efficient.

Custom resources get bundled inside of your game’s asset bundle. They are not easy to edit (or at least that used to be true). Generally if you don’t have a reason to have a custom asset be external you want it internal.

Normal assets, as in ones Defold knows about and are linked internally in your project, are automatically included in the bundle.

6 Likes

Additional information:

And some more pro’s and con’s:

  • You can’t use bundle resources in HTML5 builds (or at least not access them using io.* functions)
  • Loading from a custom resource should also be faster as there is no disk IO involved.
  • You can’t use io.* functions when loading custom resources. This means that you always read the entire file.
  • A bundle resource can use io.* function and can be read in chunks or line by line if required. Good for very large files!

EDIT: Mixed up custom vs bundle resources. Updated!

5 Likes

So custom bundle resources are used when you make the bundle and can modify the behaviour of the bundle. Is there any way to do a similar thing for HTML5 builds?

You can still use them but in a roundabout way. Load them using http.request()!

1 Like

Thanks for your answers, @britzl and @Pkeod. Exactly what I was looking for.

Can you elaborate on this a bit please? From the doc britzl linked and the project settings doc it seems to be bundled resources, not common resources, that are exposed and able to be edited by third parties. Am I missing something?

1 Like

I got them backwards in my first post. :woozy_face: Have to remember that bundle resources get included next to the binary when bundling, is not put inside of the asset bundle.

2 Likes

Terrible naming if you ask me, I always have to look it up to understand which is which. And this thread shows up in the search.
I’d rename custom resources to “pack resources” - they are packed inside the binary and you have to use sys to load them from the pack.
And bundle resources to “copy resources” - they get copied and put along with your binary.

My take:

bundle resources - I don’t see a problem with this name. These resources will be included in the application bundle. The name is pretty clear to me.

custom resources - I don’t really like this name either. I’d prefer if it was called archive_resources as these resources are included inside the game resource archive. Or perhaps game resources. It would also be great if the name clearly indicate that the resources are loaded using resource.load().

Ah, now there is resource.load() and sys.load_resource()!

archive_resources is definitely better. Archive/pack - similar words.

Also adding to the confusion is that the .ipa/.apk are also packed, and known as zip archives ^^

2 Likes

Filesystem resources? Accessed with system io calls.
Inner resources? Inside resources & Outside resources?
Hah, so confusing.

Indeed!
I think above all, a better documentation page would help a lot!

1 Like

Indeed. Here’s the manual on working with files:

PRs with improvements are appreciated!

2 Likes

Yeah, I couldn’t find it when I searched for ”bundle_resource”