1、我们有许多在线教程。点击这里去我们最后更新的网站(注意,此教程请在网上查看,翻译省略)经典GUI(教程)本教程介绍Unity图形用户接口(GUI)的主要功能。假定你没有Unity的知识。完成时间:3-4个小时经典脚本(教程)脚本是unity中的精华部分,定义你游戏的行为。本教程将介绍使用Javascript脚本的基本原理。2个小时。Introduction to the Unity Interface Unity 界面入门This tutorial will introduce the Unity graphical user interface(GUI). 本教程将介绍Unity的图形用户界
2、面(GUI)No prior knowledge of Unity isassumed. 假定没有Unity预先知识Time to complete: 1 hour. 时间 1小时Author: Graham McAllister 作者:Graham McAllisterContents 目录1. Aims of the tutorial本教程的目标2. Screen layout 屏幕布局3. Finding game objects 发现游戏对象4. Creating game objects 创建游戏对象5. Navigating the Scene View 定位场景视图6. Movi
3、ng game objects 移动游戏对象7. Game View 游戏视图8. Resizing game objects 伸缩游戏对象9. Using assets 使用资产10. Adding Components 添加组件11. Duplicate 复制(对象)1. Aims of this tutorial 教程目标If you are new to Unity this should be the rst tutorial that you read. It will explain the key sections of the interface and describe h
4、ow to create basic game objects and position them in 3D space. 如果你对Unity的不熟悉,这应该是你个阅读的第一个教程。它将讲解界面的关键章节和描述如何创建基本游戏对象和在3D空间定位它们。To demonstrate the Unity interface essentials, well create a simple scene which will allow a character to walk around on a surface. 示范Unity经典界面,我们将建立一个简单的场景,允许一个角色在表面行走。Note
5、: any text that requires the user to take an action begins with a -. 注意:需要用户创建的一个动作以“_”开始的任意字符串。2. Screen Layout 场景布局Before we start, lets make sure our screen layout is in 2 Split mode. -To ensure it is, select Window-Layouts-2 Split. Your view is now split into 5 main regions: 在我们开始之前,让我们确保我们的屏幕布局
6、在2个分割的模式。确保它是,选择Window-2 Split(窗口-布局-2个分割模式,注意:在2.5 for windows版本里没有这个布局选项)。你的视图现在是分割成5个主要区域。1 Scene View - for placing game objects 场景视图用于放置游戏对象2 Game View - this is how the game will look when run. 游戏视图它是当游戏运行时将看到外观如何。3 Hierarchy View -this is a list of all game objects currently in the scene. 层次视
7、图(面板)-场景里所有当前游戏对象的列表(清单)4 Project View -this view shows all assets that are available for use (like a palette) 项目视图(面板)-这个视图显示被应用到的可利用的所有资产(像一个选项板)。5 Inspector View -this shows the properties of the currently selected game object. 检视视图(面板,翻译成属性监视器比较合适)-它显示当前选取的游戏对象的属性。3. Finding game objects in 3D s
8、pace 在3D空间查找游戏对象-Start Unity. Well begin by creating a new project. 启动Unity,我们将通过创建一个新的项目开始。-Select File-New Project from the main menu and give the project a name such as “GUI Tutorial” and click Create Project. Unity will now import assets (e.g. audio, textures, 3D models) so they are available fo
9、r use. 从主菜单选择File-New Project(文件-新项目)并给项目一个名称例如“GUI Tutorial” 然后点击创建项目。Unity将引入资产(例如 音频、纹理、3D模型),以便它们成为使用可利用的。Once importing is complete you will be presented with your game world. At present the world only contains a Main Camera (this is default), you can see this listed as the only item in the Hie
10、rarchy view. 你一旦引入完成,在你的游戏世界将被呈现。目前,这个(游戏)世界仅包含一个主摄像机(这是默认的),你可以查看作为仅有的项目这个清单,在层次视图里。-If you cant see the camera in your Scene View, click on the Main Camera in the Hierarchy View, move your cursor so that its inside the Scene View, then type F (frame select) on the keyboard. The Main Camera should
11、now be at the centre of the Scene View. This technique can be used to nd any game object. 如果你在你的场景视图里不能看到这个摄像机,在层次视图里点击主摄像机,移动你的鼠标以至它是在场景视图里,然后在键盘上按F键(帧选择)。主摄像机现在应该在场景视图的中央。-Any game object can be selected by either clicking on it in the Scene View or selecting it in the Hierarchy View. If you click
12、 on an object in the Scene View, you can conrm that youve selected the correct object as it will also be highlighted in the Hierarchy view. 任意的游戏对象可以被选取通过任一方法,在场景视图点击它或在层次视图里选取它Lets add some game objects to our world. 让我们添加一些游戏对象到我们的世界。-Select Game Object-Create Other-Plane, this will create a plane
13、 (a 2D surface) to allow our character to walk on. 选择Game Object-Plane,这将创建一个平面(一个2D表面),允许我们的角色在上面行走。-Add a cube to the game world by selecting Game Object-Cube. 添加一个方块对到游戏世界通过选择Game Object-Cube.-Add a point light by selecting Game Object-Point Light. 添加一个点光源通过Game Object-Point Light.You can look ar
14、ound your 3D objects from any angle by using the following:你可以在任意角度(角落)查看你的3D对象通过使用下列的方法:1. Rotating (Option+LMB) 旋转 (Option +鼠标左键)2. Panning (Option+MMB) 平移 (Option +鼠标中键)3. Zooming (Option+RMB) 缩放 (Option +鼠标右键)NB: The Option key is beside the Command key (the one with the Apple logo on it) on the
15、 Mac keyboard, L/M/R MB is Left/Middle/Right Mouse Button. It is recommended that you have a 3 button mouse. 选项键是在MAC键盘上Command旁边(上面带苹果标志的键),L/M/R MB是左/中/右鼠标按钮。强烈建议你有一个3按钮的鼠标。(以上苹果机器上的操作,下面的说明可以在windows平台上使用)If you only have a one-button mouse, or are using a laptop, you can still navigate easily. F
16、irstly, click on the hand-shaped tool in the upper left hand corner of the Unity GUI, then the following can be used:如果你只有一个按钮的鼠标(注:我没有见过这样的鼠标)或使用一个膝上型电脑(笔记本电脑),你可以仍旧容易的定位。首先,在Unity GUI(图形用户界面)的左上角工具栏里点击手型按钮,然后使用下面的说明:1. Rotating (Option+LMB) 旋转(Option+鼠标左键)(在windows上 按Alt+鼠标左键)2. Panning (LMB) 平移 (
17、鼠标左键)3. Zooming (Command+LMB) -Try this now. 缩放(Command+鼠标左键)(在windows上 按windows旗标键+鼠标左键,或使用鼠标的滚轮,或先按R键,点击辅助工具(GIZMO)进行缩放),现在尝试。6. Moving game objects 移动游戏对象You can position any game object in 3D space by using one of the following:你可以在3D空间定位任意游戏对象,通过使用下列之一。1. Move tool (W on the keyboard). Selectin
18、g any game object then typing W will display three arrowheads, one for each axis of 3D space. Red is the x-axis, green is the y-axis, blue is the z-axis, i.e. r,g,b, maps to x,y,z. To move an object, click the LMB on the arrowhead that represents the axis you want to move in and move the mouse as mu
19、ch as appropriate. As you drag the arrowheads notice the objects position values in the Inspector Panel change also. You can enter values directly into these boxes also (3 boxes, 1 each for x,y,z values). 移动工具(在键盘上按W键)。选取任意游戏对象然后按W键,将显示三个箭头,一个3D空间轴的每个轴。红色是X轴,绿色是Y轴,蓝色是Z轴,也就是RGB映射到X,Y,Z。去移动一个对象,在箭头上鼠标
20、左键点击表示这个轴你想去移动并恰当的移东鼠标。当你拖动箭头,注意在检视面板里这个对象的坐标值也改变。你也可以直接键入值到这些框中(3个框,1个框是各自的x,y,z值)。You can also re-position a game object by rstly clicking on it, then move the camera to point towards the general direction of where the want the object to move to, then select Game Object-Align with View. The select
21、ed game object will move to where the camera now points. 你也可以重新配置一个游戏对象通过第一个单击,然后移动摄像机去朝向对象移动到希望地方的大体方向 。然后选择Game Object-Align with View.(游戏对象-对齐视图),选取的游戏对象将移动到摄像机新坐标的地方。2. Rotate tool (E on the keyboard). Selecting any game object then typing E will display the rotate tool. To rotate around an axis
22、, click the LMB on the axis of choice then move the mouse to rotate the game object. As you rotate the object notice the objects rotation values in the Inspector Panel change also. You can enter values directly into these boxes also. 旋转工具(在键盘上按E键)。选取任意游戏对象然后按E键将显示缩放工具。围绕一个轴旋转,在选择的轴上按鼠标左键然后移动鼠标去旋转游戏对
23、象。在你旋转对象注意在检视面板里该对象的旋转值也改变。你也可以直接键入值到这些框中。-Lets try a small exercise. Move the cube (move tool) so that it is outside of the Scene View. Use the Frame Select feature (click Cube in the Hierarchy View then press the F key) to nd the cube again. Finally move the cube back so its close to the plane. 让我
24、们做一个小练习。移动方块(移动工具)致使它处于场景视图的外面。使用帧选择特性(在层次视图(面板)里点击方块,然后按F键)重新找到这个方块。最后,向后移动方块使它接近于平板。-Move the point light so that its above the cube and the plane. 移动点光源使它处于方块和平板的上方。The Game View shows how the game will look when run (complete with textures, lighting etc). If you cannot see your game world in the
25、 Game View, its because your camera is not looking in the right direction. 游戏视图显示当游戏运行时外观如何(连通纹理、灯光等)。如果在游戏视图里,你不能看到你的游戏世界,是因为你的摄像机不在正确的方向探测。-Click on the Main Camera, you will notice an inverted yellow pyramid wireframe coming out from it. This is known as the cameras viewport (what it can see). If
26、 the viewport is not pointing in the direction of your game objects, navigate in the scene view so that you are looking at your game objects, select the Main Camera then select Game Object-Align With View. Your Game View should now match your Scene View. 在主摄像机上点击,你将注意到一个倒置的黄色倒置的金字塔线框出现。这是摄像机的视口(它看到的
27、程度)。如果视口没有指向你的游戏对象的方向,在场景视图里定位它使你看到你的游戏对象,选取主摄像机然后选取Game Object-Align With View(游戏对象-对齐视图)。你的游戏窗口现在应该匹配你的场景视图。You can also manually adjust your cameras settings by either using the move and rotate tools, or changing its transform values in the Inspector View. 你也可以手工调整你的摄像机的设置,通过任一的:使用移动和旋转工具或在检视视图(面
28、板)里更改它的变换值。You may also want to move your light to give better aesthetics. 你也同样应该移动你的灯光以提供更佳的美感。To resize an object rstly select it then press R on the keyboard (resize or scale tool). You can visually scale an object by dragging the square block at the end of the each axis, or use the Inspector Vie
29、w to type a precise value in. 伸缩一个游戏对象首先选取它然后在键盘上按R键(调整大小或缩放工具)。你可以直观的缩放一个对象通过拖动每个轴末端的四方块,或使用检视器视图(面板)去键入一个精确值。Well now resize some objects in our game world. 我们现在将伸缩一些对象在我们的游戏世界里。-Select the plane and set its x and z scale values to 10 in the Inspector view (the rst and third box, as the second box is for the y value). 选取平板并设置它的X和Z刻度值为10在检视器视图里。(第一个和第三个方框,对于第二个方框是Y的值)。-Select the cube, resize it along the y-axis visually (press R and drag the green square upward
copyright@ 2008-2022 冰豆网网站版权所有
经营许可证编号:鄂ICP备2022015515号-1