Search Unity

  1. Are you interested in providing feedback directly to Unity teams? Sign up to become a member of Unity Pulse, our new product feedback and research community.
    Dismiss Notice

How does Unity generate data.unity3d and sharedassets for scenes in the build settings?

Discussion in 'Asset Bundles' started by Xarbrough, Jul 7, 2021.

  1. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,086
    I'd like to find out if it's possible to influence the way Unity packs assets that are referenced via the build settings scenes list. For example, I have 19 scenes in my game and the following is generated when building for Android:

    upload_2021-7-7_23-40-36.png

    As I understand, most of these files are in fact AssetBundles or very similar to them, but how are these dependencies resolved? I hoped that Unity would create one resource file per scene and then another one for all shared assets, but this doesn't seem to be the case, as I have 19 scenes but only 11 resource files and one large unity3d file.

    Does anyone know what exactly goes into these files? "Unity Default Resources" speaks for itself and I won't be able to change it I assume, but what is the difference between the unity3d and resource files?

    I'm asking this, because I'm also using AssetBundles to manage certain content that is shared between scenes but not referenced directly because it may be loaded in multiple and different scenes at runtime. However, I'd like to keep things simple, so if possible, I would just use the default Unity behaviour for the rest of the scene content, if I have at least some control over it.
     
  2. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    318
    These are not influence-able. They are built and dependencies are resolved the same way as before for player data builds (build settings) and they are not asset bundles. The only difference is that they are wrapped in an Archive File to compress the results.
     
  3. Xarbrough

    Xarbrough

    Joined:
    Dec 11, 2014
    Posts:
    1,086
    Thanks for the info!

    I'm still interested in the details of how the dependencies are resolved and split into these files. I found one forum opinion saying that Unity basically takes the first scene in the build settings list, then puts all referenced assets into one archive file. Then it opens the next scene, takes all dependencies, if they are already in the first archive, do nothing, else create a new archive and so on. This sounds like Unity would create one large file for the first scene and several smaller files for all other scenes in most cases.

    Even if I can't directly control the process, I guess I can try to optimize it via the way assets are referenced and split into scenes at runtime...
     
  4. Ryanc_unity

    Ryanc_unity

    Unity Technologies

    Joined:
    Jul 22, 2015
    Posts:
    318
    That is correct with one exception:
    > puts all referenced assets
    The build pipeline is object based, not asset based. So reference pulling only pulls in referenced objects directly, not the entire asset.

    Example:
    Scene 1 directly references Mesh 1 from FBX Asset 1
    Scene 2 directly references Mesh 2 from FBX Asset 1

    Result:
    Scene 1 pulls in Mesh 1
    Scene 2 pulls in Mesh 2
    Whatever else is in FBX Asset 1 is not pulled in.
     
    OndrejP and Xarbrough like this.
unityunity