- Home /
How to correctly set bundle build order when building resources tree.
Hello everybody, I am writing a question here after struggling quit a bit with the unity bundle feature, especially regarding the setting of relationship while building asset. I have been searching extensively about this topic but could not find any suitable answer to my problem... Sorry if I missed out something.
So I am trying to build an editor tool which will help the user building asset bundle from existing resources in the project. Especially, I need to be able to build dependencies as separate bundle for different reasons (I want to be able to load asset separately in memory, as well as download them separately, avoid duplication in case asset are cross references, etc...), I was planning to use the unity push and pop feature while building bundle (taking example of the documentation sample), but it seems I cannot achieve the desired result. Let me explain the problem with a simple example, here is a simplistic tree of asset dependencies :
Following the example, the only way I could build using only push/pop would be by following the procedure :
PUSH
Build 4-5-6-7
PUSH
Build 2-3
PUSH
Build 1
This is because 1 need to know 2 and 3 before being built, and 2 and 3 need to know 4-5-6-7 before being built. This procedure involves that non-existing dependencies are created, i.e for example 3 now depends on 4 and 5, which involves several restrictions which are almost un-acceptable for my tool :
Modifying 4 or 5 will force me to rebuild 3 and re download it from the client ->almost un-acceptable.
Modifying 4 or 5 will force me to load them first in memory before loading 3, even though they have no relationships (documentation says it's mandatory to load bundle dependencies first). -> Totally un-acceptable, as this example could extrapolate to more complex situation which could end up into having to load hundreds of unrelated asset before loading the desired one.
The list of asset that have to be push into dependency before building an asset is extremely dependent on the on setting of the dependence structure at build time. Anybody changing an asset structure will modify this list and therefore I cannot be sure of which assets need to be rebuilt after this modification. (i.e the list of asset dependent a specific one is totally "setting" dependent) -> Totally un-acceptable, as I cannot guaranty all previously built asset will still be functional.
As you see, this solution using only Push/Pop functionalities is not suitable for my case. It seem to me that they were created to be used in a setting where a lot of simple asset depend on only ONE shared asset, in a kind of "Pyramidal" fashion, which is not sufficient for any serious real-life case where dependencies can be multiple and intricate.
It seems for me that the solution would be to be able to provide a list of asset ids/asset references to the BuildBundle function directly, with having to use the Push/Pop, as they are quit restrictive tool that involves the previously mentioned issues, but I couldn't come across anythings like that while reading the documentation/examples. Or maybe I totally missed something / misunderstood something (which I would actually prefer), if so please enlighten me with the truth! Or of course if anybody came up with a more efficient "crafty" solution (mine is kinda experimental and based on building tree-leaf layer or single dependent together) and feel like sharing it, that would be more than welcome :)
Sorry for the long question and thanks for any help!
Your answer
![](https://koobas.hobune.stream/wayback/20220613160433im_/https://answers.unity.com/themes/thub/images/avi.jpg)
Follow this Question
Related Questions
Why does building bundles cause unload unused assets to be called? 1 Answer
How do you properly load Asset Bundles with dependencies? 3 Answers
Serialized scene information 0 Answers
Adapt a behavior tree graph structure to quest system 0 Answers
(Asset Bundle) Skip building dependency bundles when building a bundle. 1 Answer