.prefab_引入新的Prefab工作流程

.prefab_引入新的Prefab工作流程

.prefab

One of the top requested additions to Unity is the ability to nest Prefabs. But we know a lot of you need many more changes to the Prefab workflows than that. Therefore, we’re improving the whole system with focus on reusability, control & safety. This is the first in a series of blog posts explaining the upcoming changes. If you haven’t done so already during yesterday’s Unite Berlin keynote, get the preview Unity build with the new Prefab system here.

要求最多的Unity附加功能之一是嵌套预制件的功能。 但是我们知道很多人需要对Prefab工作流程进行更多更改。 因此,我们正在着重于可重用性,控制性和安全性来改进整个系统。 这是一系列博客文章中的第一篇,解释了即将发生的变化。 如果您在昨天的Unite Berlin主题演讲中还没有这样做,请在此处使用新的Prefab系统预览Unity版本

Let’s start by recapping the basics of what Prefabs are in Unity. Fundamentally, a Prefab Asset is like a template of a GameObject and its children. You can use instances of a Prefab Asset to create many copies of a GameObject throughout your Scenes. If the Prefab Asset is changed, all the Prefab instances are automatically updated accordingly.

让我们首先回顾一下Unity中Prefabs的基础知识。 从根本上讲,预制资产就像GameObject及其子代的模板。 您可以使用预制资产实例在整个场景中创建GameObject的许多副本。 如果更改了Prefab Asset,则所有Prefab实例都会相应地自动更新。

We talked to a wide range of indie and AAA studios to dig deep into how you all work with Prefabs at the moment. An issue we found was that when you wanted to edit a Prefab Asset, you had to drag it to an open Scene in the Hierarchy to modify it, apply the changes and then remember to delete it again. Another big issue was the Apply button for Prefab instances in the Inspector. With this button, you could accidentally apply changes to the Prefab Asset that you had no good way of getting an overview of.

我们与众多独立工作室和AAA工作室进行了交谈,以深入了解目前您与Prefabs的合作方式。 我们发现的一个问题是,当您要编辑预制资产时,必须将其拖动到层次结构中打开的场景中以对其进行修改,应用更改,然后记得再次将其删除。 另一个大问题是Inspector中Prefab实例的Apply按钮。 使用此按钮,您可能会意外地将更改应用于您无法很好地概览的Prefab Asset。

To address these issues we have introduced a range of new features. We have implemented a backwards compatible Prefab backend that now supports nesting and inheritance. We have improved the visualization of property and object overrides for Prefab instances, and added the ability to apply overrides on multiple levels of granularity: per property, per Component/GameObject, or, as before, the entire Prefab instance. Lastly, we have added Prefab Mode to be able to edit a Prefab Asset in isolation.

为了解决这些问题,我们引入了一系列新功能。 我们已经实现了向后兼容的Prefab后端,该后端现在支持嵌套和继承。 我们改进了Prefab实例的属性和对象替代的可视化,并增加了在多个粒度级别上应用替代的功能:每个属性,每个Component / GameObject或像以前一样整个Prefab实例。 最后,我们添加了“预制模式”以能够单独编辑“预制资产”。

预制模式 (Prefab Mode)

Prefab Mode represents a fundamental change when working with Prefabs. It lets you decide whether you want to make changes to a Prefab instance or make changes directly to a Prefab Asset.

预制模式代表使用预制件时的根本变化。 它使您可以决定是要更改Prefab实例还是直接对Prefab资产进行更改。

Prefab Mode gives you a more controlled Prefab Asset editing session because you can perform all changes to the Prefab Asset, including structural changes, without receiving dialogs asking you to break the connection to the Prefab. With Prefab Mode, you no longer need to make temporary changes to a Prefab instance with the sole purpose of applying these changes to the Asset later (with the possible side effect of applying other previous overrides that were meant to be kept as overrides). So we recommend you use Prefab Mode for Prefab Asset changes, and only make overrides on Prefab instances when needed. Note that we have also improved the Apply workflow tremendously. More information on this workflow in an upcoming blog post!

“预制模式”使您可以更好地控制“预制资产”编辑会话,因为您可以执行对“预制资产”的所有更改,包括结构更改,而不会收到要求您断开与“预制”的连接的对话框。 使用Prefab Mode,您不再需要对Prefab实例进行临时更改,其唯一目的是稍后将这些更改应用于资产(具有应用其他先前要保留为替代的替代的可能的副作用)。 因此,我们建议您使用“预制模式”进行预制资产更改,并且仅在需要时才对预制实例进行覆盖。 请注意,我们还极大地改善了Apply工作流程。 有关此工作流程的更多信息,请参见即将发布的博客文章!

Prefab Mode takes over the Hierarchy and Scene View to show the Prefab Asset in isolation. You can recognize this mode by the new headers in the Hierarchy and Scene View. Also note that the Prefab Mode background color can be customized in the Preferences.

预制模式接管层次结构和场景视图,以单独显示预制资产。 您可以通过“层次结构和场景视图”中的新标题识别此模式。 另请注意,可以在“首选项”中自定义“预制模式”的背景色。

.prefab_引入新的Prefab工作流程

When entering Prefab Mode from the Scene, for example by clicking the arrow marked by the red circle, the Hierarchy shows the Prefab header and the Scene View shows the breadcrumbs header (marked by the red boxes).

从场景进入“预制”模式时,例如通过单击红色圆圈标记的箭头,层次结构将显示“预制”标题,而“场景视图”将显示面包屑标题(由红色框标记)。

You can enter Prefab Mode by doing one of the following:

您可以通过执行以下任一操作进入“预制模式”:

  • Double-clicking the Prefab in the Project window.

    在“项目”窗口中双击“预制件”。
  • Clicking the new arrow button in the Hierarchy window next to the root GameObject of the Prefab instance.

    单击“层次结构”窗口中Prefab实例的根GameObject旁边的新箭头按钮。
  • Clicking the Open button in the Inspector for the root GameObject of the Prefab Asset or Prefab instance.

    单击检查器中的“打开”按钮,以获取预制资产或预制实例的根GameObject。

使用预制资产 (Working with Prefab Assets)

To enable Prefab nesting, we had to make technical changes to the Prefab backend. So, technically, Prefabs are now imported Assets. This means you can no longer edit Prefab GameObjects in the Project window. Compared to the old workflow of editing directly in the Project window, Prefab Mode lets you edit objects at any depth, and see what you’re doing in the Scene view too.

为了启用Prefab嵌套,我们必须对Prefab后端进行技术更改。 因此,从技术上讲,预制件现在是进口资产。 这意味着您不能再在“项目”窗口中编辑Prefab GameObjects。 与直接在“项目”窗口中直接进行编辑的旧工作流程相比,“预制模式”使您可以在任何深度编辑对象,也可以在“场景”视图中查看正在执行的操作。

使用预制实例 (Working with Prefab instances)

Another consequence of providing Prefab nesting is that you can no longer disconnect a Prefab instance to make structural changes to that instance. This includes deleting GameObjects, reparenting GameObjects, or replacing a Transform with a RectTransform and vice versa. You can now do all of this in Prefab Mode. Alternatively, you can now unpack a Prefab instance if you want to entirely remove its link to its Prefab Asset and thus restructure the resulting plain GameObjects as you please.

提供Prefab嵌套的另一个结果是,您不再可以断开Prefab实例的连接以对该实例进行结构更改。 这包括删除GameObject,重设GameObject或用RectTransform替换Transform,反之亦然。 您现在可以在“预制模式”下完成所有这些操作。 另外,如果您想完全删除其与Prefab资产的链接,然后现在可以解包一个Prefab实例,从而根据需要重新构造最终的普通GameObjects。

预制阶段 (Prefab Stage)

We have introduced the term ‘stage’ in the Editor as a concept for a set of GameObjects isolated from other GameObjects. When you are in Prefab Mode, the breadcrumbs at the top of the Scene view each represent a different stage. Each stage is like a separate ‘world’. By default, we have the Main Stage, which is the stage where all your Scenes are (the Scenes you have loaded and can see in the Hierarchy). When opening a Prefab in Prefab Mode, we create a Prefab Stage for the contents of the Prefab. We do not unload the Main Stage GameObjects when a Prefab Stage is opened, and this means you can still see them in the Game view.

我们在编辑器中引入了“舞台”一词,作为与其他GameObject隔离的一组GameObject的概念。 当您处于“预制模式”时,“场景”视图顶部的面包屑分别代表一个不同的阶段。 每个阶段都像一个单独的“世界”。 默认情况下,我们有主舞台,这是所有场景的舞台(已加载并可以在层次结构中看到的场景)。 在“预制模式”下打开预制时,我们将为预制的内容创建一个预制阶段。 当打开预制舞台时,我们不会卸载主舞台游戏对象,这意味着您仍然可以在游戏视图中看到它们。

The Scene view and Hierarchy always show the current stage, which is the one corresponding to the rightmost breadcrumb. To go back to the Main Stage with your Scenes, either click the ‘Scenes’ button in the breadcrumbs of the Scene view or the Back arrow button in the Hierarchy.

场景视图和层次结构始终显示当前阶段,该阶段对应于最右边的面包屑。 若要返回场景的主舞台,请单击“场景”视图的面包屑中的“场景”按钮,或单击“层次结构”中的“后退”箭头按钮。

To see the new workflows in action check out the video below:

要查看新的工作流程,请观看以下视频:

To try the new Prefab features, download the preview build from our Prefab page. Also check out our dedicated forum for Improved Prefabs for more information, questions and feedback.

要尝试新的Prefab功能,请从我们的Prefab页面下载预览版本。 另外,请访问我们专用于改进预制件的论坛,以获取更多信息,问题和反馈。

Stay tuned for upcoming blog posts with more in depth information about other parts of the improved Prefab workflows.

请随时关注即将发布的博客文章,其中包含有关改进的Prefab工作流程其他部分的更多详细信息。

柏林联合艺术公司改进的预制件:今天现场直播 (Improved Prefabs at Unite Berlin: Live Today)

If you want to see the improved prefab workflows in action, we highly recommend tuning into the live stream from Unite Berlin today on YouTube or Twitch. Starting from 5pm Berlin time, you can catch Improved Prefab Workflow with Ciro Continisio. After that, Rune Skovbo Jacobsen and Steen Lund will help you better understand the pros and cons of our implementation decisions in their Technical Deep Dive into the New Prefab System (6pm). We’ll work on editing the talks later and upload them to our YouTube channel within a month after the conference.

如果您希望看到改进的预制工作流程的实际效果,我们强烈建议您立即从YouTube或Twitch上的Unite Berlin收听直播。 从柏林时间下午5点开始,您可以通过Ciro Continisio观看“ 改进的预制工作流程” 。 之后,Rune Skovbo Jacobsen和Steen Lund将帮助您更好地了解我们实施决策的利弊,方法是深入研究新的预制系统 (下午6点)。 我们将在稍后编辑演讲,并将其在会议后的一个月内上传到我们的YouTube频道。

翻译自: https://blogs.unity3d.com/2018/06/20/introducing-new-prefab-workflows/

.prefab