1. Help us improve the editor usability and artist workflows. Join our discussion to provide your feedback.
    Dismiss Notice
  2. We're looking for feedback on Unity Starter Kits! Let us know what you’d like.
    Dismiss Notice
  3. We’re giving 2017.1 beta testers a chance to win t-shirts and a Nintendo Switch. Read more on the blog.
    Dismiss Notice
  4. Unity 2017.1 beta is now available for download.
    Dismiss Notice
  5. Unity 5.6 is now released.
    Dismiss Notice
  6. Get further faster with the Unity Plus Accelerator Pack, free for new Unity Plus subscribers for a limited time. Click here for more details.
    Dismiss Notice
  7. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  8. Learn how you'll soon be able to publish your games to China in four simple steps with Xiaomi. Sign up now for early access.
    Dismiss Notice

Sharing assets across projects

Discussion in 'Editor & General Support' started by dkoontz, May 9, 2012.

  1. dkoontz

    dkoontz

    Joined:
    Aug 7, 2009
    Posts:
    198
    I'm looking for any advice the Unity community can share with me on my project's structure. The problem we are facing is that we have a large amount of assets in each of our scenes, resulting in a build that sits around 2GB. A large amount of this space is a result of each level containing roughly the same models/textures. So we would like to have only one copy of each of those assets in our project, instead of one per scene. The only way I can conceive of this is to use an assetbundle and load our models dynamically. Apart from the problems that introduces in terms of world building for the artists, we have some issues such as how do you apply a lightmap or occlusion bake to a building or statue that is dynamically loaded from an assetbundle. So before we move further along the path of using assetbundles, could someone sanity check our basic assumptions or bring up any other techniques that we're not seeing.

    In addition to the duplication of assets between scenes in this one project, there will be around 15-40% overlap in assets between this first project and our subsequent projects that will all be distributed together. So being able to have one and only one copy of our assets could prove to be a large savings in file size, assuming of course everything "just works" and doesn't cause massive problems on the production side.

    Thoughts? Ideas?
     
  2. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,349
    It's certainly possible to reuse the same 3d model across many scenes. If for some reason you can't do that, there must be something wrong. A scene only has a "link" to the asset in your assets folder and thus its possible for one 3d model/prefab to be used in many scenes.

    Ergo, one texture can be reused across many 3d models/prefabs, so the same goes for textures: they can be reused across many scenes.

    If you could show a screenshot of how things look like we may be able to help better.
     
    Last edited: Apr 6, 2013
  3. dkoontz

    dkoontz

    Joined:
    Aug 7, 2009
    Posts:
    198
    I know that is is possible to reuse an asset across scenes, that is the whole point of a prefab. What is not easy to do is to reuse assets across scenes and not have that inflate the build size.
     
  4. fffMalzbier

    fffMalzbier

    Joined:
    Jun 14, 2011
    Posts:
    2,448
    Unity automatically pack the asset , so that every asset is only existing one in the project.
    If an asset's are used in more then one scene it will be packed as an extra container , so both scene can load the same packet.

    That way the build size does not increase if you reuse assets's . (That does not only work for prefabs but for all assets)
     
  5. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,349
    Sorry I don't follow your logic. They are reused, not copied. So why would reusing inflate the build size? It doesn't store duplicate copies of the 3d files when they are reused on many scenes. As I said, the ones in your scene is just a "link" to that single 3d file, in layman's terms.



    If you're worried about your build size, you can check a breakdown of what files are in your build and how much space each takes.

    To do so, build your game to the target platform. Then go to your console window (shift ctrl C). In there you will see a button called "Open Editor Log" click it and you'll see a text file get opened (probably in Notepad).

    Search through that and a part of that log file will be a breakdown of build size. It goes something like this:

    Code (csharp):
    1.  
    2. Textures      196.4 kb   3.4%
    3. Meshes        0.0 kb     0.0%
    4. Animations    0.0 kb     0.0%
    5. Sounds        0.0 kb     0.0%
    6. Shaders       0.0 kb     0.0%
    7. Other Assets  37.4 kb    0.6%
    8. Levels        8.5 kb     0.1%
    9. Scripts       228.4 kb   3.9%
    10. Included DLLs 5.2 mb     91.7%
    11. File headers  12.5 kb    0.2%
    12. Complete size 5.7 mb     100.0%
    13.  
    14.  
    15. Used Assets, sorted by uncompressed size:
    16.  39.1 kb     0.7% Assets/BTX/GUI/Skin/Window.png
    17.  21.0 kb     0.4% Assets/BTX/GUI/BehaviourTree/Resources/BehaviourTreeGuiSkin.guiskin
    18.  20.3 kb     0.3% Assets/BTX/Fonts/DejaVuSans-SmallSize.ttf
    19.  20.2 kb     0.3% Assets/BTX/Fonts/DejaVuSans-Bold.ttf
    20.  20.1 kb     0.3% Assets/BTX/Fonts/DejaVuSansCondensed 1.ttf
    21.  12.0 kb     0.2% Assets/BTX/Fonts/DejaVuSansCondensed.ttf
    22.  10.8 kb     0.2% Assets/BTX/GUI/BehaviourTree/Nodes2/White.png
    23.  8.1 kb  0.1% Assets/BTX/GUI/BehaviourTree/Nodes/RoundedBox.png
    24.  8.1 kb  0.1% Assets/BTX/GUI/BehaviourTree/Nodes/Decorator.png
    25.  4.9 kb  0.1% Assets/BTX/GUI/Skin/Box.png
    26.  4.6 kb  0.1% Assets/BTX/GUI/BehaviourTree/GlovedHand.png
    27. (and so on)
    28.  
    I kinda wish there was a front-end GUI that shows this though. Its probably easy to make one actually...
     
    theANMATOR2b likes this.
  6. AnomalusUndrdog

    AnomalusUndrdog

    Joined:
    Jul 3, 2009
    Posts:
    1,349