欢迎光临散文网 会员登陆 & 注册

Unity_Addressable_在编辑器中管理Addressable

2023-03-30 10:13 作者:unity_某某师_高锦锦  | 我要投稿

While it's impossible to comprehensively catalog all the different ways you can organize the assets in your project, Organizing Addressable assets outlines several considerations to take into account when you plan your organizational strategy.

译:虽然不可能对项目中组织资产的所有不同方式进行全面编目,但组织可寻址资产概述了在规划组织策略时需要考虑的几个因素。

You should also understand How Addressables interact with your Project assets while you consider how to manage your assets.

译:在考虑如何管理您的资产时,您还应该了解Addressables如何与您的项目资产交互。

Addressable Groups are the primary unit of organization with which you manage Addressable assets. An important consideration when using Addressables are your options for Packing groups into AssetBundles.

译:可寻址组是管理可寻址资产的主要组织单位。在使用Addressables时,一个重要的考虑因素是将组打包到资产包中的选项。

In addition to your group settings, you can use the following to control how Addressables work in a project:

译:除了组设置外,您还可以使用以下功能来控制可寻址对象在项目中的工作方式:

  • Addressable Asset Settings: the Project-level settings译:Addressable Asset Settings 工程登记设置

  • Profiles: defines collections of build path settings that you can switch between depending on the purpose of a build. (Primarily of interest if you plan to distribute content remotely.)译:Profiles定义构建路径设置的集合,您可以根据构建的目的在这些设置之间进行切换。(如果您计划远程分发内容,主要是感兴趣的。)

  • Labels: edit the Addressable asset labels used in your project.译:Labels:编辑项目中使用的可寻址资产标签。

  • Play Mode Scripts: choose how the Addressables system loads assets when you enter Play mode in the Editor.译:Play Mode Scripts:当你在编辑器中进入播放模式时,选择Addressables系统如何加载资产。

AssetReferences provide a UI-friendly way to use Addressable assets. You can include AssetReference fields in your MonoBehaviour and ScriptableObject classes and then assign assets to them in the Editor using drag-and-drop or the object picker dialog.

译:资产引用提供了一种用户界面友好的方式来使用可寻址资产。您可以在MonoBehaviour和ScriptableObject类中包含AssetReference字段,然后在编辑器中使用拖放或对象选择器对话框将资产分配给它们。

The Addressables system provides the following additional tools to aid development:

译:Addressables系统提供了以下额外的工具来帮助开发:

  • Analyze tool: provides various analysis rules that you can run to verify that you have organized your assets the way you want, including a report on how Addressables will package your assets into bundles.译:Analyze tool:提供各种分析规则,您可以运行这些规则来验证您已经按照您想要的方式组织了您的资产,包括一个关于Addressables如何将您的资产打包成包的报告。

  • Event viewer: provides a profile view that shows when your assets are loaded and released. Use the Event viewer to verify that you are releasing assets and to monitor peak memory use.译:Event viewer:提供一个概要文件视图,显示何时加载和释放资产。使用事件查看器来验证您正在释放资产并监视峰值内存使用。

  • Hosting Service: provides a simple asset server that you can use to host remote assets for local development.译:Hosting Service:提供一个简单的资产服务器,您可以使用它托管远程资产以进行本地开发。

  • Build layout report: provides a description of the AssetBundles produced by a build.译:Build layout report:提供由构建生成的资产包的描述

  • Build profile log: provides a log profiling the build process itself so that you can see which parts take the longest.译:Build profile log:提供构建过程本身的日志分析,以便您可以查看哪些部分花费的时间最长。

Organizing Addressable Assets

There’s no single best way to organize your assets; it depends on the specific requirements of each project. Aspects to consider when planning how to manage your assets in a project include:

译:没有唯一的最佳方式来组织你的资产;这取决于每个项目的具体要求。在计划如何管理项目中的资产时,需要考虑的方面包括:

  • Logical organization: keeping assets in logical categories can make it easier to understand your organization and spot items that are out of place.译:Logical organization:将资产保持在逻辑类别中可以使您更容易理解您的组织并发现不合适的项目

  • Runtime performance: performance bottlenecks can occur if your bundles become very large, or alternatively if you have a very large number of bundles.译:Runtime performance: 如果您的bundle变得非常大,或者您有非常多的bundle,就会出现性能瓶颈

  • Runtime memory management: keeping assets together that you use together can help lower peak memory requirements.译:Runtime memory management:将一起使用的资产放在一起可以帮助降低峰值内存需求。

  • Scale: some ways of organizing assets might work well in small games, but not large ones, and vice versa.译:Scale: 一些组织资产的方法可能适合小型游戏,但不适用于大型游戏,反之亦然

  • Platform characteristics: the characteristics and requirements of a platform can be a large consideration in how to organize your assets. Some examples:译:Platform characteristics在如何组织资产时,平台的特征和需求可能是一个很大的考虑因素。一些例子

    • Platforms that provide abundant virtual memory can handle large bundle sizes better than those with limited virtual memory.译:与虚拟内存有限的平台相比,提供丰富虚拟内存的平台可以更好地处理大容量的包

    • Some platforms don't support downloading content, ruling out remote distribution of assets entirely.译:有些平台不支持下载内容,完全排除了资产的远程分发

    • Some platforms don't support AssetBundle caching, so putting assets in local bundles, when possible, is more efficient.译:有些平台不支持AssetBundle缓存,因此尽可能将资产放在本地bundle中会更有效

  • Distribution: whether you distribute your content remotely or not means, at the very least, that you must separate your remote content from your local content.译:Distribution:无论您是否远程分发您的内容,至少意味着您必须将远程内容与本地内容分开

  • How often assets are updated: keep assets that you expect to update frequently separate from those that you plan to rarely update.译:资产更新的频率:将您希望频繁更新的资产与您计划很少更新的资产分开

  • Version control: the more people who work on the same assets and asset groups, the greater the chance for version control conflicts to occur in a project.译:Version control:在相同资产和资产组上工作的人越多,项目中发生版本控制冲突的可能性就越大

Common strategies

Typical strategies include:

译:典型策略包括:

  • Concurrent usage: group assets that you load at the same time together, such as all the assets for a given level. This strategy is often the most effective in the long term and can help reduce peak memory use in a project.译:并发使用:将您同时加载的资产组合在一起,例如给定关卡的所有资产。从长期来看,这种策略通常是最有效的,可以帮助减少项目中的峰值内存使用

  • Logical entity: group assets belonging to the same logical entity together. For example, UI layout assets, textures, sound effects. Or character models and animations.译:逻辑实体:将属于同一逻辑实体的资产分组在一起。例如,UI布局资产,纹理,音效。或者角色模型和动画。

  • Type: group assets of the same type together. For example, music files, textures.译:类型:将相同类型的资产组合在一起。例如,音乐文件,纹理。

Depending on the needs of your project, one of these strategies might make more sense than the others. For example, in a game with many levels, organizing according to concurrent usage might be the most efficient both from a project management and from a runtime memory performance standpoint. At the same time, you might use different strategies for different types of assets. For example, your UI assets for menu screens might all be grouped together in a level-based game that otherwise groups its level data separately. You might also pack a group that contains the assets for a level into bundles that contain a particular type of asset.

译:根据项目的需要,其中一种策略可能比其他策略更有意义。例如,在一款拥有许多关卡的游戏中,根据并发使用进行组织可能是最有效的方法,无论是从项目管理还是从运行时内存性能的角度来看。与此同时,您可以针对不同类型的资产使用不同的策略。例如,在基于关卡的游戏中,你的菜单屏幕UI资产可能都被组合在一起,否则它的关卡数据就会被单独分组。您还可以将包含关卡资产的组打包到包含特定类型资产的包中。

See Preparing Assets for AssetBundles for additional information.

译:有关更多信息,请参见为资产包准备资产。


Safely editing loaded Assets

You can safely edit loaded Assets in the following situations:

译:在以下情况下,您可以安全地编辑加载的资产:

  • The Asset is loaded from an Asset Bundle.译:资产是从AB资产包中加载的

  • The application is running in a Player, not in the Editor.译:应用程序运行在播放器中,而不是在编辑器中

  • When you enable the Use Existing Build (requires built groups) option in Play Mode Scripts.译:当您在播放模式脚本中启用Use Existing Build (需要构建组)选项时

In these cases, the Assets exist as a copy in active memory. Changes made to these copied Assets don't affect the saved Asset Bundle on disk and any changes don't persist between sessions.

译:在这些情况下,资产作为一个副本存在于活动内存中。对这些复制的资产所做的更改不会影响磁盘上保存的资产包,并且会话之间的任何更改都不会持久。

For other situations, including when you enable the Use Asset Database (fastest) or Simulate Groups (advanced) properties in the playmode settings, Unity loads the Assets directly from the Project files. This means that Unity saves any modifications to the Asset during runtime to the Project Asset file and that those changes will persist between different sessions.

译:对于其他情况,包括当你在播放模式设置中启用使用资产数据库(最快)或模拟组(高级)属性时,Unity直接从项目文件中加载资产。这意味着Unity在运行时将对资产的任何修改保存到项目资产文件中,并且这些更改将在不同的会话之间持续存在。

If you want to make runtime changes to an Asset, Unity recommends that you create a new instance of the GameObject you want to modify and use the copy for any runtime changes. This eliminates the risk that you might accidentally modify the original Asset file. The following code example demonstrates creating a new copy of a loaded Asset:

译:如果你想要对资产进行运行时更改,Unity建议你创建一个你想要修改的游戏对象的新实例,并使用该副本进行任何运行时更改。这消除了您可能不小心修改原始Asset文件的风险。下面的代码示例演示了如何创建已加载资产的新副本:

If you use the above method to use a copy of an Asset, be aware of the following:

译:如果您使用上述方法来使用资产的副本,请注意以下事项:

  • You must use either the original Asset or the AsyncOperationHandle when you release the Asset, not the current instance of the Asset.译:当您释放资产时,必须使用原始资产或AsyncOperationHandle,而不是资产的当前实例

  • When you instantiate an Asset that has references to other Assets in this way, Unity doesn't create new instances of the referenced Assets. The references for the newly instantiated copy target the original Project Asset.译:当你以这种方式实例化一个有其他资产引用的资产时,Unity不会创建被引用资产的新实例。新实例化的副本的引用以原始项目资产为目标。

  • Unity invokes MonoBehaviour methods like Start(), OnEnable(), and OnDisable() on the new instance.译:Unity在新实例上调用MonoBehaviour方法,如Start(), OnEnable()和OnDisable()。



Unity_Addressable_在编辑器中管理Addressable的评论 (共 条)

分享到微博请遵守国家法律