使用 Inspector 窗口可对 Unity 编辑器中几乎所有内容(包括游戏对象、Unity 组件、资源、材质)查看和编辑属性和设置,以及查看和编辑编辑器内的设置和首选项。
要打开 Inspector 窗口,请执行以下操作之一:
可以打开所需数量的 Inspector 窗口,并且可以对它们进行重新定位、停靠和调整大小,和其他任何窗口的方式一样。
默认情况下,Inspector 窗口显示当前选择的属性。每当选择更改时,Inspector 窗口的内容便会更改。要保持打开同一组属性而无论当前选择如何,请执行以下操作之一:
可以在 Inspector 窗口中查看和编辑的内容取决于所选择的内容。本部分介绍对于可以选择的不同类型的项,Inspector 窗口所显示的内容。
选择游戏对象时(例如在 Hierarchy 或 Scene 视图中),Inspector 会显示其所有组件和材质的属性。可以在 Inspector 窗口中编辑属性和重新排列组件。
当游戏对象附加了自定义脚本组件时,Inspector 会显示脚本的公共变量。可以采用与编辑任何其他属性相同的方式编辑脚本变量,这意味着可以在脚本中设置参数和默认值而无需修改代码。
有关更多信息,请参阅脚本部分中的变量和 Inspector。
选择资源时(例如通过 Project 窗口),Inspector 会显示控制 Unity 如何在运行时导入和使用资源的设置。
每种类型的资源都有自己的设置。在 Inspector 窗口中编辑的资源导入设置示例包括:
打开 Project Settings 时(菜单:Editor > Project Settings),Unity 会将它们显示在 Inspector 窗口中。
处理预制件时,Inspector 窗口会显示一些附加信息并提供一些附加选项。例如:
有关在 Inspector 窗口中处理预制件的更多信息,请参阅预制件部分。
选择了两个或更多项时,可以在 Inspector 窗口中编辑它们共有的所有属性。Unity 会将提供的值复制到所有选定项。Inspector 窗口会显示选定项的数量。
选择多个游戏对象时,Inspector 窗口会显示它们共有的所有组件。
选择相同类型的多个资源时,Inspector 窗口会显示它们共有的所有属性。
选择不同类型的多个资源时,Inspector 会显示一个列表,其中显示选择的每种类型资源的数量。单击该列表中的任何项可检查该类型的所有资源。
可以采用与编辑多个游戏对象相同的方式检查预制件的多个选定实例,但 Inspector 会隐藏 Select、Revert 和 Apply 按钮(请参阅通过预制件的实例编辑预制件)。
在 Inspector 窗口中打开游戏对象或资源时,可以使用 Ping 命令在 Scene 视图或 Project 视图中查找它。
从 Inspector 窗口的 More Items (⋮) 菜单,选择 Ping。Unity 在 Hierarchy 视图或 Project 视图中突出显示该项目。
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.