Assigning References 指定引用

Date:2011-08-01

Reference properties are properties that reference other objects such as GameObjects, Components, or Assets. The reference slot will show what kind of objects can be used for this reference.

引用(参照)属性是这样一种属性,它可以引用其它对象如游戏对象、组件或资源。引用槽(就是那个输入框)会显示可以用于此位置的对象种类。

The Audio Clip property slot shows that it accept references to objects of type Audio Clip
Audio Clip属性槽显示它可以引用的音频剪辑类对象

Now an Audio Clip file is referenced in the Audio Clip property.
现在一个音频文件被引用到了Audio Clip属性上

This type of referencing is very quick and powerful, especially when using scripting. To learn more about using scripts and properties, please view the Scripting Tutorial on the tutorials page.

这种引用的类型是非常快速和强大的(我很想翻译成给力的),尤其是使用脚本的时候。要了解更多有关使用脚本和属性的内容,请查看教程页面上的脚本指南。

Object references can be assigned to a reference property either by drag and drop or by using the Object Picker.

可以通过拖放或者使用对象选取器这两种方式给一个引用(参照)属性指定对象。

Drag and Drop 拖放

You can use drag and drop simply by selecting the desired object in the Scene View, Hierarchy, or Project View and dragging it into the slot of the reference property.

你可以在场景视图、层次视图、或项目视图中选择所需的对象,将它拖到参照属性的引用槽。

If a reference property accepts a specific Component type (for example a Transform) then dragging a GameObject or a Prefab onto the reference property will work fine provided that the GameObject or Prefab contains a component of the correct type. The property will then reference the component in question, even though it was a GameObject or Prefab you dragged onto it.

如果参照属性接受一种特殊的组件类型(如Transform组件),那么拖放一个游戏对象或预设件到参照属性上也能很好地工作,前提是该游戏对象或预设件包含一个正确类型的组件,参照属性仍将引用这个有问题的组件,尽管它是一个你拖过来的游戏对象或预设件。

If you drag an object onto an reference property, and the object is not of the correct type, or does not contain the right component, then you won't be able to assign the object to the reference property.

如果你拖动一个对象到参照属性上,该对象是不正确的类型或没有包含正确的组件,那么你将不能够指派该对象到参照属性上。

The Object Picker 对象选择器

You can click on the small target icon next to a reference slot to open the Object Picker.

你可以点击引用槽旁边的小图标来打开对象选取器。如图:


References to the Object Picker from the Editor. 通过编辑器的对象选择器提供引用

The Object Picker is a simple window for assigning objects in the inspector after allowing you to preview and search those available.

对象选取器是一个简单窗口,可以让你预览和搜索到可用对象之后,在检视视图中指定。

Although the Object Picker is really easy to use, there are a few things you should be aware of. These are described below.

虽然对象选取器是很容易使用的,但仍有一些事情是你应该知道的,说明如下。


Anatomy of the Object Picker. 对象选择器的界面说明

  1. Search: When there are lots of objects in the picker, you can use the Search field to filter them. This search field can also search objects using their Labels.
    搜索:当选择器中有很多对象,你可以使用搜索字段来筛选他们,搜索字段也可以使用标签来搜索对象。(关于标签,请参阅资源工作流程)
  2. View Selector: Switches the base of the search between objects in the scene and assets.
    视图选择器:切换显示搜索到的场景对象和资源对象。
  3. Preview Size: This horizontal scroll bar lets you increase/decrease the size of your preview objects in the preview window. With this you can see more or fewer objects in the preview window at any moment.
    预览大小:这个水平滚动条可以让你增大/减小在预览窗口中的预览对象的大小。这样你可以在预览窗口中看到更多或更少的对象。
  4. Preview Window: Here are all the objects that reside in your Scene/Assets folder filtered by the Search field.
    预览窗口:这里是由搜索字段筛选出的你的场景/资源文件夹里的所有对象。
  5. Object Info: Displays information about the currently selected object. The content of this field depends on the type of object being viewed, so if for example you pick a mesh, it will tell you the number of vertices and triangles, and whether or not it has UV's and is skinned. However, if you pick an audio file it will give you information such as the bit rate of the audio, the length, etc.
    对象信息:显示当前选择的对象的信息。此区域的内容取决于当前查看对象的类型,例如,如果你选择一个网格,它会告诉你顶点和三角形的数量,是否有UV,是否有蒙皮;如果你选择一个音频文件,它将给你音频比特率、长度等信息。
  6. Object Preview: This also depends on the type of object you are viewing. If you select a mesh, it will display you how the mesh looks, but if you select a script file, it will just display an icon of the file.
    对象预览:这也取决于你当前查看对象的类型。如果您选择一个网格,它会显示你怎样观察网格,但如果你选择一个脚本文件,它只会显示该文件的图标。

The Object Picker works on any asset you have in your project, which can be a video, a song, a terrain, a GUI skin, a scripting file, or a mesh; it is a tool you will use often.

对象选择器工作于项目中的任何资源上,它可以是一个视频、歌曲、地形、图形用户界面的皮肤(GUI skin以后这个词不翻译为好)、脚本文件、网格,它是一个你会经常使用的工具。

Hints 提示

  • Use Labels on your Assets and you will be able to find them more easily by searching for them using the search field of the Object Picker
    在资源上使用标签,将能够使你在对象选取器中利用搜索字段更容易找到它们。
  • If you dont want to see the descriptions of the objects you can move the slider in the bottom middle of the preview window downward.
    如果你不想看到对象的描述,你可以向下拖动预览窗口底部中间的滑块。
  • If you want to see a detailed preview of the object, you can enlarge the object preview by dragging the slider in the bottom middle of the preview window.
    如果你想看到对象的详细预览,你可以通过拖动在预览窗口底部中间的滑块来放大对象预览。
分类:Manual|评论: 0|浏览: 251 翻译: 第七把剑
评论
暂无评论
发表评论
用户名:

评论审核后才会显示!