要编辑预制件资源,请在预制件模式下将其打开。预制件模式允许您单独查看和编辑预制件资源的内容(独立于场景中的所有其他对象)。在预制件模式下所做的更改会影响该预制件的所有实例。
可通过多种方法在预制件模式下开始编辑预制件,包括:
进入预制件模式会使 Scene 视图和 Hierarchy 窗口仅显示该预制件的内容。在此处,预制件的根是常规游戏对象:没有蓝色的预制件实例图标。
在预制件模式下,Scene 视图会在顶部显示一个示踪导航栏。最右边的条目是当前打开的预制件。使用示踪导航栏可导航回主要场景或可能已打开的其他预制件资源。
此外,Hierarchy 窗口在顶部显示一个预制件标题栏,其中显示当前打开的预制件。可以使用标题栏中的后退箭头向后导航一步,这相当于单击 Scene 视图的示踪导航栏中的上一级示踪导航。
预制件模式在 Scene 视图的右上角有一个 Auto Save 设置。启用此设置后,对预制件所做的任何更改都会自动保存到预制件资源。默认情况下会启用 Auto Save。
如果希望在进行更改时不自动将这些更改保存到预设资源,请关闭 Auto Save。在这种情况下,当退出当前预制件的预制件模式时,系统会询问是否要保存未保存的更改。如果在预制件模式下编辑预制件时看起来很慢,关闭 Auto Save 可能会有所帮助。
在预制件模式下对预制件资源进行更改时,只能在仍处于预制件模式下时才能撤消这些更改。在给定的预制件资源退出预制件模式后,与该预制件资源有关的编辑在撤消历史记录中将不再可用。
可为预制件模式指定一个场景作为__编辑环境__,这样便可以根据选择的背景(而不是空场景)编辑预制件。这对于了解预制件与游戏中的典型景物的对比情况非常有用。
在预制件模式下,指定为编辑环境的场景中的对象是不可选择的,也不会在 Hierarchy 窗口中显示。这是为了让您专注于编辑预制件而不会意外地选择其他不相关的对象,并且没有混乱的 Hierarchy 窗口。
要将场景设置为编辑环境,请打开 Editor 窗口(顶部菜单:__Edit > Project Settings__,然后选择 Editor 类别),然后选择 Prefab Editing Environment 部分。对于“非 UI”预制件,请使用 Regular Environment 设置,而对于 UI 预制件,请使用 UI Environment 设置。UI 预制件是在根上具有矩形变换 (Rect Transform) 组件而不是常规变换组件的预制件。“非 UI”预制件是具有常规变换组件的预制件。
2018–07–31 页面已发布
在 2018.3 版中添加了嵌套预制件和预制件变体
Did you find this page useful? Please give it a rating:
Thanks for rating this page!
What kind of problem would you like to report?
Thanks for letting us know! This page has been marked for review based on your feedback.
If you have time, you can provide more information to help us fix the problem faster.
Provide more information
You've told us this page needs code samples. If you'd like to help us further, you could provide a code sample, or tell us about what kind of code sample you'd like to see:
You've told us there are code samples on this page which don't work. If you know how to fix it, or have something better we could use instead, please let us know:
You've told us there is information missing from this page. Please tell us more about what's missing:
You've told us there is incorrect information on this page. If you know what we should change to make it correct, please tell us:
You've told us this page has unclear or confusing information. Please tell us more about what you found unclear or confusing, or let us know how we could make it clearer:
You've told us there is a spelling or grammar error on this page. Please tell us what's wrong:
You've told us this page has a problem. Please tell us more about what's wrong:
Thank you for helping to make the Unity documentation better!
Your feedback has been submitted as a ticket for our documentation team to review.
We are not able to reply to every ticket submitted.