Unity 使用场景模板来创建新场景。场景模板可视为一个预先配置好的场景,其中包含您想要作为创建起点的所有内容。例如,默认的 Basic 模板通常包含一个摄像机和一个光源。
您可以创建自己的场景模板来自定义可在项目中创建的新场景的类型。例如,您可以为游戏中的每个关卡创建模板,以便参与该项目的每个人都可以使用正确的资源和配置开始创建各自的场景。
您可以从任何 Unity 场景创建模板。创建模板后,您可以利用该模板创建任意数量的新场景。与场景一样,大多数场景模板都是存储在项目中的资源。
本页面解释了重要的场景模板概念。有关创建、编辑和管理场景模板的更多信息,请参阅以下页面:
大多数场景模板都是用户定义的,这意味着您可以从自己的场景中创建它们。用户定义的场景模板是 Unity 存储在项目中的资源。
Unity 还为每种项目类型提供了内置模板。例如,某些项目类型包括一个 Basic 模板,可创建带有摄像机和光源的场景,以及一个创建空场景的 Empty 模板。
内置模板不同于其他模板,因为它们不是项目中存储的资源,您无法对其进行修改。
注意: |
---|
某些 Unity 包可能还包含一些场景模板,在您安装包时会安装这些模板。 |
创建场景模板时,您可以指定在将其用于创建新场景时 Unity 是克隆还是引用其依赖项(它包含的资源)。
要指定 Unity 为特定模板克隆哪些资源,请编辑模板的属性。
典型的模板可能包含克隆资源和引用资源的混合。默认情况下,Unity 设置了几种要克隆的资源类型。
要更改默认情况下 Unity 是克隆还是引用给定资源类型,请编辑场景模板项目设置。
克隆资源是模板场景使用的原始资源的副本。当 Unity 从模板创建新场景时,它会自动修改新场景以使用任何克隆的资源。如果您修改克隆的资源,它不会影响模板场景。如果在模板场景中修改原始资源,则不会影响新场景。
当您希望新场景包含用户可能会修改的一组起始资源时,克隆模板资源非常有用。
引用资源是模板场景使用的原始资源。当 Unity 从模板创建新场景时,新场景指向与模板场景相同的资源。如果您修改这些资源,新场景和模板场景都会受到影响。
当您希望新场景包含用户作为构建基础但不修改的默认资源集时,引用模板资源非常有用。
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.