zoukankan      html  css  js  c++  java
  • AssetBundle依赖

    Managing asset dependencies

      一个Asset会依赖其它Asset。可以把一个Asset所依赖的Asset也打包进自己的AssetBundle。可是多个Asset可能依赖同一个/多个Asset。If a separate copy of a shared dependency is included in each bundle that has objects using it, then redundant instances of the assets will be created when the bundles are loaded. This will result in wasted memory.

      To avoid such wastage, it is possible to separate shared dependencies out into a separate bundle and simply reference them from any bundles with assets that need them.

      First, the referencing feature needs to be enabled with a call to BuildPipeline.PushAssetDependencies. Then, the bundle containing the referenced dependencies needs to be built. 

      Next, another call to PushAssetDependencies should be made before building the bundles that reference the assets from the first bundle. Additional levels of dependency can be introduced using further calls to PushAssetDependencies. 

      The levels of reference are stored on a stack, so it is possible to go back a level using the correspondingBuildPipeline.PopAssetDependencies function. 

      At runtime, you need to load a bundle containing dependencies before any other bundle that references them. For example, you would need to load a bundle of shared textures before loading a separate bundle of materials that reference those textures.

    注:以上是Unity老版本特性。在老版本中,Unity需要手动添加dependency。而在新版本中,无而手管理依赖关系,PushAssetDependencies API已经被移除。

    Asset IDs

      If you anticipate needing to rebuild asset bundles that are part of a dependency chain then you should build them with theBuildAssetBundleOptions.DeterministicAssetBundle option enabled. This guarantees that the internal ID values used to identify assets will be the same each time the bundle is rebuilt.

      When building the asset bundle with this method, the objects in it are assigned a 32 bit hash code that is calculated using the name of the asset bundle file, the GUID of the asset and the local id of the object in the asset. For that reason make sure to use the same file name when rebuilding. Also note that having a lot of objects might cause hash collisions preventing Unity from building the asset bundle.

      

  • 相关阅读:
    产品开源了(discuz!nt 2.0),顺便将前些时候发的文章做个总结
    一个曾经的"愤青梦"弥衡
    推荐两个web菜单控件(右击和顶部主菜单)
    一本晚看了两年半的书蓝海战略
    Discuz!NT 在线用户功能简介
    我的2007
    ajax.net调用session和cookie
    最新(2010年)搜索引擎优化(SEO)专家工具集合
    Android学习资料大全
    基于.net的aop实现技术
  • 原文地址:https://www.cnblogs.com/tekkaman/p/4031390.html
Copyright © 2011-2022 走看看