Preset Manager 是 Project Settings 中的一个窗口(菜单:__Edit__ > Project Settings > __Preset Manager__),用于管理自定义预设,当您将组件添加到游戏对象或将新资源添加到您的项目时,自定义预设将指定默认属性。您定义的默认预设会覆盖 Unity 的默认设置。
__注意:__不能为项目设置、偏好设置或本机资源(如材质、动画或精灵图集)设置默认属性。
除了在创建新组件和导入资源时使用默认预设之外,使用 Inspector 窗口的组件上下文菜单中的 Reset 命令时,Unity 也会使用默认预设。
属性 | 描述 |
---|---|
Filter | 使用 Filter 字段来定义预设应用于哪些组件或导入器。 |
Preset | 使用 Preset 字段设置要使用的预设。默认情况下,预设会在您创建后应用于该预设类型的所有组件或资源导入器。如果您只想将其应用于特定组件或资源类型,请使用 Filter 字段来定义何时应用预设。 |
Add Default Preset | Select this button to choose the Importer, Component, or ScriptableObject to add a Preset to. If you choose Importer or Component, select the type of asset importer or component you want to create a Preset for. |
要在 Preset Manager 中指定要用于默认设置的预设:
如果项目中还没有用于默认设置的预设,请创建一个。
通过选择 Edit > Project Settings__,然后选择 Preset Manager__ 打开 Preset Manager。
选择 Add Default Preset 并选择默认类型。
您选择的预设类型出现在 Preset Manager 列表中。
在 Preset 字段中,单击__Preset selector__(圆圈图标)。
从 Select Preset 窗口,为此预设类型选择一个预设。
或者,您也可以将预设从 Project 窗口拖放到 Preset 字段中。
若要向列表中添加另一个 Preset 字段,请单击 Add (+) 选项卡。
注意:__创建新游戏对象时,对于变换组件,Unity 不会使用默认预设中的 Position 值。相反,它将默认位置值设置为 Scene 视图的中心。要将 Position 值设置为默认预设的值,请选择变换组件的 More items__ 按钮 (⋮) 并选择 Reset。
您还可以通过 Inspector 窗口添加并删除用于默认设置的预设。
添加默认预设:
在 Project 窗口中选择一个预设。
在 Inspector 窗口,单击 Add to default。
Unity 将您的默认预设添加到 Preset Manager。
打开 Preset Manager 将过滤器添加到预设或重新排序您的预设列表。
删除默认预设:
默认情况下,预设会在创建后应用于该预设类型的所有组件或资源导入器。如果您只想将其应用于特定组件或资源类型,可以使用 Filter 字段来定义何时应用预设。
过滤器允许您为给定类型创建多个预设,并根据这些组件和导入器是否满足过滤条件将它们应用到特定组件或导入器。您可以按文件名、目录和文件扩展名进行过滤。
您也可以应用部分预设,仅影响您在组件或资源中指定的属性。
注意:预设类型中的默认预设按从上到下的顺序应用。这意味着如果未按逻辑顺序排列,列表底部的过滤器会覆盖之前的过滤器。
Presets can use glob search, which is a way to use symbols in your filters to allow for more inclusive import filters. See the table below for a list of symbols you can use. A glob search filter is case-sensitive.
To create a glob search filter, the syntax is glob:"yoursearchpatternhere"
. Your filter field must begin glob:
, and the search term must be in quotation mark characters. For example, glob:"example-folder/*.fbx"
filters for any .fbx file in a folder called example-folder.
支持的符号:
符号 | 描述 | 示例 |
---|---|---|
* | 匹配单一路径部分中的 0 个或多个字符(单一路径部分定义为去除 / 后的任一字符组) |
glob:"foldername/*.fbx" searches for any .fbx file located in a folder named foldername. |
? | 匹配 1 个字符 |
glob:"foldername/filename-?.fbx" 搜索位于名为 foldername 的文件夹中满足以下条件的 .fbx 文件:_filename-_ 后跟有一个字符 (例如,这将包括 filename–1.fbx、filename–2.fbx_,但不包括 filename–01.fbx_)。 |
[…] | 匹配一系列字符,类似于一个 RegExp 范围。如果该范围的第一个字符是 ! 或 ^,则匹配该范围之外的任何字符。 |
glob:"foldername/file[...]1.fbx" 搜索位于名为 foldername 的文件夹中满足以下条件的 .fbx 文件:以 file 开头,以 1 结尾 (例如,这将包括 file–1.fbx、file–01.fbx_,但不包括_file–2.fbx_)。| (pattern|pat*|pat?erN) | 使用括号内以垂直管道字符(意思是“或”)分隔的搜索,表示过滤结果可以匹配其中的搜索模式之一。| glob:("foldername/*.fbx"\|"foldername/filename-?.fbx") searches for any .fbx file located in a folder named foldername, or any .fbx file located in a folder named foldername_ that has the name filename- followed by one single character. |
** | 搜索匹配项时匹配零个或多个的目录和子目录。 |
glob:"foldername/**.fbx" searches for any .fbx file located in a folder named foldername. or its subfolders. |
本节介绍如何在 Preset Manager 的默认预设列表中为每种预设类型切换、移动和删除预设。
您可以暂时禁用/启用默认预设而不会丢失过滤器设置。
通过选择 Edit > Project Settings__,然后选择 Preset Manager__ 类别来打开 Preset Manager。
清除默认预设左侧的复选框以禁用预设。选中复选框则启用。
PresetManager
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.