• 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.

      

  • 相关阅读:
    元宇宙通证
    高性能公链
    区块链不可能三角
    搭建自己的在线API文档系统
    windows 安装python环境
    golang beego项目的正确开启方法
    人生发财靠康波
    蒙代尔不可能三角
    Kubernetes 部署Dashboard UI
    Kubernetes 使用kubeadm创建集群
  • 原文地址:https://www.cnblogs.com/tekkaman/p/4031390.html
Copyright © 2020-2023  润新知