Using the Inspector 使用检视视图

优质
小牛编辑
131浏览
2023-12-01

The Inspector is used to view and edit Properties of many different types.

检视视图用于查看和编辑不同类型的属性。

Games in Unity are made up of multiple GameObjects that contain meshes, scripts, sounds, or other graphical elements like Lights. When you select a GameObject in the Hierarchy or Scene View, the Inspector will show and let you modify the Properties of that GameObject and all the Components and Materials on it. The same will happen if you select a Prefab in the Project View. This way you modify the functionality of GameObjects in your game. You can read more about the GameObject-Component relationship, as it is very important to understand.

Unity的游戏都是由包含网格、脚本、声音或其他图形元素(比如光源)的多个游戏对象所构成。当你在层次视图或场景视图中选择一个游戏对象,检视视图会显示它并且可以让你修改游戏对象的属性和所有组件及材质。当你在项目视图中选择一个预设件,也同样可以这样,用这种方法你可以修改游戏对象的功能。你可以阅读GameObject-Component relationship,因为它是非常重要的。

 

检视视图显示游戏对象和其组件及材质的属性
Inspector shows the properties of a GameObject and the Components and Materials on it.
检视视图显示游戏对象和其组件及材质的属性

When you create a script yourself, which works as a custom Component type, the member variables of that script are also exposed as Properties that can be edited directly in the Inspector when that script component has been added to a GameObject. This way script variables can be changed without modifying the script itself.

当你创建一个脚本,它将作为一个自定义的组件类型,当这个脚本组件被添加到一个游戏对象中时,该脚本的成员变量将作为可直接编辑的属性陈列在检视视图中。这样以来无需修改脚本本身就可以直接改变其变量。

Furthermore, the Inspector is used for showing import options of assets such as textures, 3D models, and fonts when selected. Some scene and project-wide settings are also viewed in the Inspector, such as all the Settings Managers.

此外,检视视图也用于显示资源的导入选项,如纹理、三维模型、选择字体。某些场景和项目范围的设置也可以在检视视图中来查看,如所有的设置管理器。

Any property that is displayed in the Inspector can be directly modified. There are two main types of Properties: Values and References.

检视视图中显示的任何属性都可以直接修改,有两种主要类型的属性:赋值属性和参照(引用)属性。