Unity3D 官方基础教程 Learning the Interface

来源:互联网 发布:工商管理硕士就业知乎 编辑:程序博客网 时间:2024/05/01 10:39

Learning the Interface

First Launch

Let's begin learning Unity. If you have not yet opened Unity, you can find it inside Start->Programs->Unity on Windows, or Applications->Unity on Mac. The Unity Editorwill appear. Take your time to look over the Unity Editor interface and familiarize yourself with it. The Main Editor Window is made up of several Tabbed Windows, calledViews. There are several types of Views in Unity, each with a specific purpose.

让我们开始学习Unity。如果你还没有打开过Unity,你可以在Windows系统中通过 开始→程序→Unity 来打开,或者在MAC系统中通过 应用程序→Unity 来打开。打开 Unity 你将会看到编辑器。你可以浏览并熟悉一下 Unity 编辑器的界面。主编辑器窗口是由许多标签窗口组成,称为视图。Unity 中有几种类型的视图,每一种都有其特殊的目的。


Project View(项目视图)



Every Unity project contains an Assets folder. The contents of this folder are presented in the Project View. This is where you store all the assets that make up your game, like scenes, scripts3D modelstexturesaudio files, and Prefabs. If you right-click on any asset in the Project View, you can choose Reveal in Explorer (Reveal in Finderon Mac) to actually see the asset itself in your file system.

Important Note: You should never move project assets around using the OS since this will break any metadata associated with the asset. Always use the Project View to organize your assets

每个 Unity 项目都含有一个 Assets 文件夹。文件夹里的东西都呈现在项目视图。这个文件夹储存了组成游戏的所有资源,例如场景、脚本、3D模型、纹理、音频文件和预设物。如果右键单击视图中的任何资源,你就可以选择 Reveal in Explorer (Reveal in Finder on Mac) 在文件系统中查看资源本身。

切记:绝不可以在操作系统里移动项目资源,这样将会损坏一些与资源关联的元数据。总是使用项目视图去组织你的资源。

To add assets to your project, you can drag any file from your OS into the Project View, or use Assets->Import New Asset. Your asset is now ready to be used in your game. For more information about working with assets, skip ahead to the Asset Workflow section of the manual.

Scenes are also stored in the Project View. Think of these as individual levels. For example, the Islands Scene loads by default when Unity first launches. To create a new Scene, use Control-N (Command-N on Mac). To save the current Scene into the Project View, use Control-S (Command-S on Mac).

你可以从操作系统中拖拽任何文件到项目视图中,或者使用 Assets→Import New Asset 来向项目中添加资源。这样就可以在游戏中使用这些资源。更多关于使用资源的信息,可以跳至用户手册中 Asset Workflow 一节

场景依然存储在项目视图中。可以认为这些场景是单独存在的。例如, 当首次登陆 Unity 时默认加载孤岛场景。使用 Control-N (Command-N on Mac) 创建新的场景。使用 Control-S (Command-S on Mac) 保存项目视图中当前的场景。

Some game assets need to be created from within Unity. To do this, use the Create drop-down, or right click->Create.

一些游戏资源需要在 Unity 中创建。点击 Create 下拉菜单或者通过 单击右键→Create 来在 Unity 中创建资源。


The Create drop-down (下拉菜单)

This will allow you to add scripts, Prefabs, or folders to keep your project organized. You can rename any asset/folder by pressing F2 on Windows, or Enter on Mac, or with two paced clicks on the asset name. If you hold the Alt key while you expand or contract a directory, all subdirectories will also be expanded or contracted.

Create 下拉菜单允许添加脚本、预设物,或者添加文件夹来保持项目结构清晰。你可以在 Windows 系统中按 F2 键来重命名任何资源/文件夹,或者在 Mac 系统中按 Enter 键,也可以通过双击资源名称来重命名。 如果你按住 Alt 键不放,当展开或收缩一个目录时,所有的子目录也将展开或收缩。


Hierarchy(层次视图)



The Hierarchy contains every GameObject in the current Scene. Some of these are direct instances of asset files like 3D models, and others are instances of Prefabs -- custom objects that will make up much of your game. You can select and Parent objects in the Hierarchy. As objects are added and removed from the scene, they will appear and disappear from the Hierarchy as well.

层次结构视图含有当前场景中的所有游戏对象(GameObject)。其中一些是直接实体资源文件像3D模型,其他是预设实体–用户自定义对象将会是游戏的最大组成部分。你可以在 Hierarchy 视图中选择对象和父对象。如果对象在视图中被添加或移除,它们同样也会在层次结构视图中出现或消失。

Parenting(父处理)

Unity uses a concept called Parenting. To make any GameObject the child of another, drag the desired child onto the desired parent in the Hierarchy. A child will inherit the movement and rotation of its parent. You can now expand and contract the parent to see its children in the Hierarchy without affecting your game.

Unity 使用一个 父处理 的概念。创建任何游戏对象的其他子对象,可以在层次结构视图中拖拽子对象到父对象上。一个子对象将会继承父对象的运动和旋转。在层次结构视图中展开或收缩父对象可以看到子对象而不会影响游戏。


Two unparented objects(两个原对象)


One object parented to another(其中一个对象变成另一个对象的父对象)

To learn more about Parenting, please review the Parenting section of the Transform Component page.

更多关于父处理,请浏览组件转换页面的父处理一节。


Toolbar(工具栏)


The Toolbar consists of five basic controls. Each relate to different parts of the Editor.
工具栏包含了五个基本控件。每一个控件涉及到编辑器的不同部分。

 Transform Tools -- used with the Scene View  转换工具 – 使用于场景视图
Transform Gizmo Toggles -- affect the Scene View display  转换线框开关 – 影响场景视图显示
Play/Pause/Step Buttons -- used with the Game View  播放/暂停/下一步按钮 – 使用于游戏视图
 Layers Drop-down -- controls which objects are displayed in Scene View 层下拉 – 控制哪些对象显示在场景视图中
Layout Drop-down -- controls arrangement of all Views 布局下拉 – 控制所有视图的布局

Scene View(场景视图)

The Scene View 场景视图

The Scene View is your interactive sandbox. You will use the Scene View to select and position environments, the player, the camera, enemies, and all other GameObjects. Maneuvering and manipulating objects within the Scene View are some of the most important functions in Unity, so it's important to be able to do them quickly.

场景视图是你的互动沙箱。你将会使用场景视图来选择和放置环境、玩家、摄像机、敌人以及其他所有的游戏对象。在场景视图中机动和操纵物体是 Unity 非常重要的功能之一,因此能够快速的使用它们是非常重要的

Scene View Navigation 场景视图导航

See Scene View Navigation for full details on navigating the scene view. Here's a brief overview of the essentials:
领会场景视图导航的细节在于亲自使用它。这里只是简单的概述下需要先了解的一些知识

  • Hold the right mouse button to enter Flythrough mode. This turns your mouse and WASD keys (plus Q and E for up and down) into quick first-person view navigation.
  • Select any GameObject and press the F key. This will center the Scene View and pivot point on the selection.
  • Use the arrow keys to move around on the X/Z plane.
  • Hold Alt and click-drag to orbit the camera around the current pivot point.
  • Hold Alt and middle click-drag to drag the Scene View camera around.
  • Hold Alt and right click-drag to zoom the Scene View. This is the same as scrolling with your mouse wheel.

按住鼠标右键进入飞行穿越(Flythrough)模式。这会把你的鼠标和 WASD 键(加上 Q 和 E 键,向上和向下)进入快速第一人称视角的导航。选择任何游戏对象并且按 F 键。这将会场景视图移至中央并且轴心点在选择的物体上。
使用箭头键在X/Z平面上移动。
按住 Alt 键并单击拖动摄像机轨道绕着当前的轴心点。
按住 Alt 键并单击鼠标中键拖动场景视图中的摄像机移动。
按住 Alt 并单击鼠标右键拖动,缩放场景视图。这和滚动鼠标滚轮效果相同。

You might also find use in the Hand Tool (shortcut: Q), especially if you are using a one-button mouse. With the Hand tool is selected,
你可能也会发现并使用手形工具(快捷键:Q),特别是如果你正在使用一键式鼠标。手形工具被选中时,

Click-drag to drag the camera around. 单击并拖动可以拖动摄像机的位置
Hold Alt and click-drag to orbit the camera around the current pivot point. 按住 Alt 键单击并拖动可以拖动摄像机轨道绕着轴心点运动。
Hold Control (Command on Mac) and click-drag to zoom the camera. 按住 Control 键(MAC 系统按住 Command 键)并且单击并拖动缩放摄像机。

In the upper-right corner of the Scene View is the Scene Gizmo. This displays the Scene Camera's current orientation, and allows you to quickly modify the viewing angle.在场景视图的右上角有场景导航。 这里显示了场景摄像机当前的方向,并且允许你快速的修改观察视角


You can click on any of the arms to snap the Scene Camera to that direction and change it to Isometric Mode. While in Isometric Mode, you can right-click drag to orbit, and Alt-click drag to pan. To exit this mode, click the middle of the Scene Gizmo. You can also Shift-click the middle of the Scene Gizmo any time to toggle Isometric Mode.

你可以单击任何导航方向标去改变场景摄像机的方向,讲起改为等距模式(Isometric Mode)。而在等距模式下,你可以右键单击拖动到轨道,并且按住 Alt 单击拖动摄像机镜头。单击场景导航块中心,退出等距模式。任何时候你都可以按住 Shift 键单击场景导航块中心切换到等距模式。

Positioning GameObjects(定位游戏对像)

See Positioning GameObjects for full details on positioning GameObjects in the scene. Here's a brief overview of the essentials:

更详细的了解场景中定位游戏对象的内容可以看定位游戏对象一节。这里是简单的概述一些必备知识:


When building your games, you'll place lots of different objects in your game world. To do this use the Transform Tools in the Toolbar to Translate, Rotate, and Scale individual GameObjects. Each has a corresponding Gizmo that appears around the selected GameObject in the Scene View. You can use the mouse and manipulate any Gizmo axis to alter the Transform Component of the GameObject, or you can type values directly into the number fields of the Transform Component in the Inspector.

当创建游戏时,你将会在你的游戏世界里放置很多不同的物体。可以使用工具条中的转换工具去移动、旋转和缩放每个游戏对象。在场景视图中每个所选对象周围都会出现相应的线框。你可以使用鼠标控制物体线框来改变游戏对象,或者你可以直接在参数窗口中直接输入转换的数值

Scene View Control Bar(场景视图控制栏)


The Scene View control bar lets you see the scene in various view modes - Textured, Wireframe, RGB, Overdraw, and many others. It will also enable you to see (and hear) in-game lighting, game elements, and sound in the Scene View. See View Modes for all the details.

场景视图控制栏允许你用多种查看模式 - 纹理、线框、RGB、透支等很多其他模式。这也会使你能够在场景视图中看到(听到)- 游戏照明、游戏元素和声音。详细内容请查看查看模式一节。

Game View(游戏视图)


The Game View is rendered from the Camera(s) in your game. It is representative of your final, published game. You will need to use one or more Cameras to control what the player actually sees when they are playing your game. For more information about Cameras, please view the Camera Component page.

游戏视图是由游戏中的摄像机渲染。这代表了你最终发布的游戏效果。你将会需要使用一个或多个摄像机去控制玩家在玩游戏时实际所看到的场景。 请浏览摄像机组件一节来获得更多关于摄像机的信息。


Play Mode(播放模式)


Use the buttons in the Toolbar to control the Editor Play Mode and see how your published game will play. While in Play mode, any changes you make are temporary, and will be reset when you exit Play mode. The Editor UI will darken to remind you of this.
使用工具栏的播放模式按钮去控制编辑器播放模式并且了解你最终发布的游戏效果。当在播放模式下,任何改变都是临时的,当离开播放模式时所有的都会被重置。播放模式下编辑器的界面将会变暗。

Game View Control Bar(游戏视图控制条)


The first drop-down on the Game View control bar is the Aspect Drop-down. Here, you can force the aspect ratio of the Game View window to different values. It can be used to test how your game will look on monitors with different aspect ratios.

游戏视图控制条中第一个下拉菜单是外观下拉菜单。在这里你可以改变游戏视图窗口不同的长宽比。这可以用来测试你的游戏在不同长宽比的屏幕下的显示效果。

Further to the right is the Maximize on Play toggle. While enabled, the Game View will maximize itself to 100% of your Editor Window for a nice full-screen preview when you enter Play mode.

进而右边的是最大化播放开关。当进入播放模式时,游戏视图将会以100%全屏预览模式显示在编辑器窗口中。

Continuing to the right is the Gizmos toggle. While enabled, all Gizmos that appear in Scene View will also be drawn in Game View. This includes Gizmos drawn using any of the Gizmos class functions.
在右边的是Gizmos开关。当Gizmos打开时,所有出现在场景视图中的Gizmos将会出现在游戏视图中。This includes Gizmos drawn using any of the Gizmos class functions.

Finally we have the Stats button. This shows Rendering Statistics window that is very useful for Optimizing Graphics Performance.
最后的是统计按钮。这将会显示统计窗口,对于优化图形处理器性能非常有用。


Game View Stats of your game. 游戏视图中统计效果

Inspector(监视器)


Games in Unity are made up of multiple GameObjects that contain meshes, scripts, sounds, or other graphical elements like Lights. The Inspector displays detailed information about your currently selected GameObject, including all attached Components and their properties. Here, you modify the functionality of GameObjects in your scene. You can read more about the GameObject-Component relationship, as it is very important to understand.

在Unity中游戏是由多样的游戏对象组成,游戏对象包含网格、脚本和其他的图像的元素如灯光。监视器中详细显示了当前选择的游戏对象的信息,包括所有的附加组件和他们的属性。监视器中你可以修改场景中游戏对象的功能。你可以在游戏对象-组件关系一节获得更多信息,这对你理解监视器非常重要。

Any property that is displayed in the Inspector can be directly modified. Even script variables can be changed without modifying the script itself. You can use the Inspector to change variables at runtime to experiment and find the magic gameplay for your game. In a script, if you define a public variable of an object type (like GameObject or Transform), you can drag and drop a GameObject or Prefab into the Inspector to make the assignment.
任何显示在监视器中的属性值都可以直接修改。甚至可以更改脚本变量无需修改脚本本身。你可以使用监视器去更改变量在运行时去实验,最终找到最佳的游戏设置。在一个脚本里,如果你定义了一个公共变量的对象类型(如游戏对象或转换),你可以拖动或下拉一个游戏对象或预设物到监视器上直接进行赋值。

Click the question mark beside any Component name in the Inspector to load its Component Reference page. Please view the Component Reference for a complete and detailed guide to all of Unity's Components.
单击监视器中组建名旁边的问号标记,加载它的组件参照也。请浏览组件参照一节获得所有unity组件的完整详细的指导。


Add Components from the Component menu 在组件菜单里添加组件

You can click the tiny gear icon (or right-click the Component name) to bring up a context menu for the specific Component.
对于特殊的组件,你可以单击小齿轮图标(或右键点击组件名称)去打开一个内容菜单


The Inspector will also show any Import Settings for a selected asset file. 对于一个选定的资源文件夹监视器同样也会显示任何导入的设置


Click Apply to reimport your asset. 单击应用,再输入你的资源。

Use the Layer drop-down to assign a rendering Layer to the GameObject. Use the Tag drop-down to assign a Tag to this GameObject.
使用层下拉菜单去制定一个游戏对象的渲染层。使用标签下拉菜单去制定一个游戏对象的标签。 

Prefabs(预设物)

If you have a Prefab selected, some additional buttons will be available in the Inspector. For more information about Prefabs, please view the Prefab manual page.
如果你已经选择了预设物,监视器中一些额外的按钮将会启用。请浏览预设物手册一节,获得更多关于预设物的信息。

Other Views(其它视图)

The Views described on this page covers the basics of the interface in Unity. The other Views in Unity are described elsewhere on separate pages:
这一节包含了Unity基本的界面视图的描述。unity其他视图的描述在单独的页面:

  • The Console shows logs of messages, warnings, and errors.
  • The Animation View can be used to animate objects in the scene.
  • The Profiler can be used to investigate and find the performance bottle-necks in your game.
  • The Asset Server View can be used to manage version control of the project using Unity's Asset Server.
  • The Lightmapping View can be used to manage lightmaps using Unity's built-in lightmapping.
  • The Occlusion Culling View can be used to manage Occlusion Culling for improved performance.

    控制台显示的日志消息、警告和错误。
    动画视图可用于在场景中设置动画对象。
    分析器可用于调查和发现游戏性能的瓶颈。
    资源服务器视图可于来管理版本控制使用Unity的资源服务器。
    光影贴图视图可以被用来管理灯光贴图使用Unity内置的光影贴图。
    遮挡裁剪视图可用于管理遮挡裁剪提升性能。





原创粉丝点击