固定资产期初导入_新的资产导入管道:加快资产导入的坚实基础

固定资产期初导入

As of 2019.3, the new Asset Import Pipeline is the default for new projects, aiming to save you time with faster platform switching and laying the foundation for faster imports. We’re also making the asset pipeline scale better for very large projects. Read on to find out more about the new improvements, and our motivation and considerations.

自2019.3起,新的资产导入管道是新项目的默认设置,旨在通过更快的平台切换为您节省时间,并为更快的导入奠定基础。 我们还将使大型项目的资产管道规模更好。 请继续阅读以了解有关新改进以及我们的动机和注意事项的更多信息。

Whenever you put a new asset into your project, it doesn’t actually become a part of the project until the Asset Import Pipeline discovers and imports it. The correct detection of the project state is what the Asset Import Pipeline is responsible for while allowing you to query for this state through various APIs.

每当您将新资产放到项目中时,实际上直到资产导入管道发现并导入它后,它才真正成为项目的一部分。 资产导入管道负责正确检测项目状态,同时允许您通过各种API查询此状态。

In 2017, the Asset Import Pipeline rewrite work began to pave the way towards a more robust and scalable approach, while also addressing a number of pain points reported by you in your daily workflows. With Unity 2019.3 (now available in beta), the new Asset Import Pipeline (also known as Asset Import Pipeline V2) will be the default implementation for new projects. Older projects can choose to upgrade to the new Asset Import Pipeline to get the benefits of this new system.

2017年,资产导入管道的重写工作开始为更健壮和可扩展的方法铺平道路,同时还解决了您在日常工作流程中报告的许多难题。 使用Unity 2019.3(现已在 beta中提供 ),新的资产导入管道(也称为资产导入管道V2)将成为新项目的默认实现。 较旧的项目可以选择升级到新的“资产导入管道”,以获得该新系统的好处。

Now is a good time to share some of the thinking behind the new pipeline. Specifically, we want to share the considerations taken to make sure the new system is compatible with the existing APIs so that scripts will not have to be re-written when upgrading to the new Asset Import Pipeline.

现在是分享新管道背后的一些想法的好时机。 具体来说,我们希望分享确保新系统与现有API兼容的考虑因素,以便在升级到新的Asset Import Pipeline时不必重写脚本。

演示地址

实现更快的导入时间 (Achieving faster import times)

There are numerous workflows that are part of a daily development cycle. We have identified the most time-consuming issues and have implemented solutions for them.

日常开发周期中包含许多工作流。 我们已经确定了最耗时的问题,并为他们实施了解决方案。

Importing assets can take a long time. Converting the source data to a format that the Unity Editor, or a platform, is ready to utilize is not a trivial process. For example, importing a complex 3D model requires a large number of computations, and when combined with animation this time can quickly grow.

导入资产可能需要很长时间。 将源数据转换为Unity Editor或平台可以使用的格式并不是一件容易的事。 例如,导入复杂的3D模型需要进行大量计算,并且当与动画结合使用时,这个时间可以快速增长。

To address this there are 3 key concepts which need to be addressed as part of the solution:  

为了解决这个问题,有3个关键概念需要作为解决方案的一部分加以解决:

导入结果 (Import Result)

With most types of assets, Unity needs to convert the data from the source file, depending on the target platform for your projects. The result will vary between compatible GPU formats such as PVRTC, ASTC or ETC. 

对于大多数类型的资产,Unity需要根据 项目目标平台 从源文件转换数据 。 结果在兼容的GPU格式(例如PVRTC,ASTC或ETC)之间会有所不同。

This is because most file formats are optimized to save storage, whereas in a game or any other real-time application, the asset data needs to be in a format ready for immediate use by hardware, such as the CPU, graphics, or audio hardware.

这是因为大多数文件格式都经过优化以节省存储空间,而在游戏或任何其他实时应用程序中,资产数据必须采用可立即由硬件(例如CPU,图形或音频硬件)使用的格式。 。

For example, when Unity imports a PNG image file as a texture, it doesn’t use the original PNG-formatted data at runtime. Instead, when the texture is imported, Unity creates a new representation of the image in a different format which is stored in the project’s Library folder. This imported version is what is used by the Texture class in the engine, and uploaded to the GPU for real-time display. This is referred to as the Import Result.

例如,当Unity导入PNG图像文件作为纹理时,它在运行时不会使用原始的PNG格式的数据。 相反,导入纹理后,Unity会以另一种格式创建图像的新表示形式,并将其存储在项目的“库”文件夹中。 此导入的版本是引擎中的Texture类使用的版本,并上传到GPU进行实时显示。 这被称为 导入结果

决定论 (Determinism)

We need to know that both you and I get the same Import Results in the same exact format when we import, even when we’re using different hardware. The principle of getting the same output for a given input is what we call determinism. 

我们需要知道,即使我们使用的是不同的硬件,在导入时您和我也会以相同的准确格式获得相同的导入结果。 对于给定的输入,获得相同输出的原理是确定性。

依赖追踪 (Dependency Tracking)

The Asset Import Pipeline keeps track of all the dependencies for each asset and keeps a cache of the imported versions of all the assets. An asset’s import dependencies are all the data that could influence the import result. This means that if any of your asset’s import dependencies are changed, the cached version of the imported asset becomes outdated, and the asset needs to be re-imported to reflect those changes.

资产导入管道跟踪每个资产的所有依赖关系,并保留所有资产的导入版本的缓存。 资产的导入依存关系是所有可能影响导入结果的数据。 这意味着,如果您资产的任何导入依赖项发生了变化,则导入资产的缓存版本将过时,并且需要重新导入资产以反映​​这些更改。

引入新的资产导入管道 (Introducing the new Asset Import Pipeline)

There are different situations where importing can take a long time. We’ve identified the following two workflows and implemented two solutions to address the above issues: Fresh Project Import and Fast Platform Switching.

在不同的情况下,导入可能需要很长时间。 我们已经确定了以下两个工作流程,并实现了两个解决方案来解决上述问题: Fresh Project ImportFast Platform Switching

新鲜项目导入 (Fresh Project Import)

When you set up a project for the first time, it’s essentially the same as when the Library folder is deleted. This means that every asset in the assets folder needs to be enumerated and imported by the Asset Import Pipeline. This is naturally an expensive operation. However, by ensuring that our import process is deterministic and stable across machines, the time it takes to retrieve import results can be reduced by many orders of magnitude, depending on the size of the Source Asset and the size of the Import Result.

首次设置项目时,它与删除“库”文件夹时基本相同。 这意味着资产文件夹中的每个资产都需要由资产导入管道进行枚举和导入。 这自然是昂贵的操作。 但是,通过确保我们的导入过程在所有计算机上都是确定性的和稳定的,可以将检索导入结果所花费的时间减少多个数量级,具体取决于源资产的大小和导入结果的大小。

We achieve this by using the new Unity Accelerator which caches import results on the cloud from anyone who is connected to it, thus allowing you to directly download the import results from a server rather than having to go through the heavy processing which importing an asset would entail.

我们通过使用新的 Unity Accelerator 来 实现此目的,该 Unity Accelerator 将来自连接到它的任何人的导入结果缓存在云中,从而使您可以直接从服务器下载导入结果,而不必经历繁琐的处理过程,因为导入资产会需要。

快速平台切换 (Fast Platform Switching)

Up until Unity 2019.2 (with the original Asset Import Pipeline), the Library folder was comprised of the GUIDs of Assets being their filename. Thus, switching from a platform to another platform would invalidate the Import Result in the Library folder, causing it to be re-imported every time you switch platforms.

直到Unity 2019.2(具有原始的“资产导入管道”),“库”文件夹由资产的GUID组成,即其文件名。 因此,从一个平台切换到另一个平台将使 Library 文件夹中 的Import Result无效 ,从而导致每次切换平台时都将其重新导入。

Asset Import Pipeline V1

资产导入管道V1

If you had to switch back and forth between platforms multiple times per day, this could easily take up hours, depending on your project size.

如果您每天必须在平台之间来回切换多次,这可能很容易花费几个小时,具体取决于您的项目规模。

Some of you have figured out workarounds for this, such as having a copy of your project per platform on your machine, but that doesn’t scale very well.

你们中的一些人已经找到了解决方法,例如在机器上的每个平台上都拥有一份项目副本,但是扩展性不是很好。

With the new Asset Import Pipeline, we’ve removed the GUID to File Name mapping. Since dependencies for a particular Asset are tracked, we are able to Hash them all together to create a revision for the Import Result of an Asset. This allows us to have multiple revisions per Asset, which then means that we are no longer bound by a GUID to File Name mapping. Not having this requirement allows us to have Import Results which work across different configurations. For Fast Platform Switching, we could have an Import Result per platform, so that when you switch platforms back and forth the Import Result is already there, thus making the platform switch many orders of magnitude faster than with the Asset Import Pipeline V1.

通过新的资产导入管道,我们删除了GUID到文件名的映射。 由于跟踪了特定资产的依赖关系,因此我们能够将它们全部散列在一起,以创建资产导入结果的修订版。 这使我们可以对每个资产进行多个修订,这意味着我们不再受限于GUID到文件名的映射。 没有此要求使我们可以拥有跨不同配置工作的导入结果。 对于快速平台切换,我们可以为每个平台提供一个导入结果,因此,当您来回切换平台时,导入结果已经存在,从而使平台切换比使用Asset Import Pipeline V1快许多个数量级。

Asset Import Pipeline V2

资产导入管道V2

可能的缺点 (Possible downside)

As you make changes to assets, Unity generates a number of new files that will get generated. This will take up more storage space on your disk. However, the way we have decided to approach this issue is to remove unused Import Results when Unity restarts. We keep track of the latest import result per platform so that Fast Platform Switching can still take place while older Import Results are removed, thus helping you free up some of your disk space.

在更改资产时,Unity会生成许多新文件,这些文件将被生成。 这将占用磁盘上的更多存储空间。 但是,我们决定解决此问题的方法是在Unity重新启动时删除未使用的导入结果。 我们会跟踪每个平台的最新导入结果,以便在删除较旧的导入结果时仍可以进行快速平台切换,从而帮助您释放一些磁盘空间。

如何升级到新的资产导入管道 (How to upgrade to the new Asset Import Pipeline)

The new Asset Import Pipeline is available with Unity 2019.3 beta. If you have an existing project, you can upgrade to the new Asset Import Pipeline using the Project Settings Window in the Editor:

Unity 2019.3 beta版提供了新的资产导入管道。 如果您有现有项目,则可以使用 编辑器中的 “ 项目设置”窗口 升级到新的“资产导入管道

Selecting Version 2 will tell the editor you now want to use the new Asset Import Pipeline together with this project, and restarting your project will re-import it using the new Asset Import Pipeline code. This essentially has the same effect as deleting your Library folder, but without deleting it. When switching to use Asset Import Pipeline V2, the Import Results from the original Asset Import Pipeline are not deleted as V2 creates its own folder structure to store its Import Results.

选择 版本2 将告诉编辑器您现在要与该项目一起使用新的Asset Import Pipeline,重新启动您的项目将使用新的Asset Import Pipeline代码将其重新导入。 从本质上讲,这与删除“库”文件夹具有相同的效果,但不会删除它。 切换为使用资产导入管道V2时,原始资产导入管道的导入结果不会被删除,因为V2创建了自己的文件夹结构来存储其导入结果。

Projects that you’ve created in Unity 2019.2 or older will still use the original Asset Import Pipeline by default. When opening such a project in Unity 2019.3 for the first time, you’ll get an option to upgrade to the new Asset Import Pipeline. If you decline, your project will continue using the original Asset Import Pipeline. Furthermore, the selected version is stored in the EditorSettings.asset file of your project, so it can be version controlled.

在Unity 2019.2或更早版本中创建的项目在默认情况下仍将使用原始的资产导入管道。 首次在Unity 2019.3中打开此类项目时,您将获得一个升级到新的Asset Import Pipeline的选项。 如果您拒绝,则您的项目将继续使用原始的“资产导入管道”。 此外,所选版本存储在项目的EditorSettings.asset文件中,因此可以对其进行版本控制。

使用新的资产导入管道创建的新项目 (New Projects created with the new Asset Import Pipeline)

When creating a new Project with Unity 2019.3 or newer, the new Asset Import Pipeline has become the new default way to work. All new projects you create will be using it.

使用Unity 2019.3或更高版本创建新项目时,新的资产导入管道已成为新的默认工作方式。 您创建的所有新项目都将使用它。

即将有更多改进 (More improvements coming)

At Unite Copenhagen 2019, our team presented two talks. My talk is a general introduction to the topics covered in this blog post and can guide your decision-making for your own Asset Management strategies. My colleague Jonas Drewsen talked about the upcoming features directed towards making the asset pipeline more extensible and ensuring project stability:

在2019年哥本哈根联合会上,我们的团队进行了两次演讲。 我的演讲 是对本博客文章所涵盖主题的一般介绍,并且可以指导您制定自己的资产管理策略的决策。 我的同事Jonas Drewsen谈到了即将到来的功能,这些功能旨在使资产管道更加可扩展并确保项目稳定性:

演示地址

现在在Unity 2019.3 Beta中可用 (Now available in Unity 2019.3 beta)

Get the Unity 2019.3 beta and try out the new Asset Import Pipeline. We’re looking forward to hearing what you think on the forum! You can also get in touch with me on Twitter if you have further questions.

获取 Unity 2019.3 beta版 并尝试新的资产导入管道。 我们期待 在论坛上 听到您的想法 ! 如果您还有其他疑问,也可以在Twitter上与我联系。

翻译自: https://blogs.unity3d.com/2019/10/31/the-new-asset-import-pipeline-solid-foundation-for-speeding-up-asset-imports/

固定资产期初导入

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值