失眠网,内容丰富有趣,生活中的好帮手!
失眠网 > Unity3D中文手册1

Unity3D中文手册1

时间:2021-10-02 08:17:42

相关推荐

Unity3D中文手册1

LearningtheInterface(学习界面)

FirstLaunch(第一次运行)

Let'sbeginlearningUnity.IfyouhavenotyetopenedUnity,youcanfinditinsideStart->Programs->UnityonWindows,orApplications->UnityonMac.TheUnityEditorwillappear.TakeyourtimetolookovertheUnityEditorinterfaceandfamiliarizeyourselfwithit.TheMainEditorWindowismadeupofseveralTabbedWindows,calledViews.ThereareseveraltypesofViewsinUnity,eachwithaspecificpurpose.

让我们开始学习Unity。如果你还没有打开Unity,你可以在Windows里面找到开始->程序->Unity启动它,或者在Mac系统中通过Applications->Unity启动它。你自己可以观察Unity编辑器界面并熟悉它。主编辑器窗口是由几个选项卡式窗口组成,称之为视图。在Unity中,有不同类型的特殊用途的视图。

ProjectView(项目视图)

EveryUnityprojectcontainsanAssetsfolder.ThecontentsofthisfolderarepresentedintheProjectView.Thisiswhereyoustorealltheassetsthatmakeupyourgame,likescenes,scripts,3Dmodels,textures,audiofiles,andPrefabs.Ifyouright-clickonanyassetintheProjectView,youcanchooseRevealinExplorer(RevealinFinderonMac)toactuallyseetheassetitselfinyourfilesystem.

每个Unity的项目包含一个资源文件夹。此文件夹的内容呈现在项目视图。这里存放着你游戏的所有资源,比如场景、脚本、三维模型、纹理、音频文件和预制组件。如果你在项目视图里右击任何资源,你都可以在资源管理器中(在Mac系统中是RevealinFinder)找到这些真正的文件本身。

ImportantNote:YoushouldnevermoveprojectassetsaroundusingtheOSsincethiswillbreakanymetadataassociatedwiththeasset.AlwaysusetheProjectViewtoorganizeyourassets.

重要提示:不要使用操作系统来移动项目资源,因为这将破坏与资源相关的一些元数据。你应该始终使用项目视图来组织自己的资源。

Toaddassetstoyourproject,youcandraganyfilefromyourOSintotheProjectView,oruseAssets->ImportNewAsset.Yourassetisnowreadytobeusedinyourgame.Formoreinformationaboutworkingwithassets,skipaheadtotheAssetWorkflowsectionofthemanual.

要添加资源到你的项目中,你可以拖动操作系统的任何文件到项目视图,或者使用Assets->ImportNewAsset导入新资源。你的资源现在可以在你的游戏中使用了。如需更多使用资源的信息,直接跳到资源工作流程手册。

ScenesarealsostoredintheProjectView.Thinkoftheseasindividuallevels.Forexample,theIslandsSceneloadsbydefaultwhenUnityfirstlaunches.TocreateanewScene,useControl-N(Command-NonMac).TosavethecurrentSceneintotheProjectView,useControl-S(Command-SonMac).

SomegameassetsneedtobecreatedfromwithinUnity.Todothis,usetheCreatedrop-down,orrightclick->Create.

场景也存储在项目视图中。想想这些独特的层次。例如,Unity第一次启动时默认加载的“孤岛危机”场景。要创建新的场景,使用Ctrl+N(在Mac系统中使用Command-N),要在项目视图中保存当前场景,使用Ctrl+S(在Mac系统中使用Command-S)。

有些游戏资源必须从Unity内部建立。要做到这一点,使用Create下拉菜单,或通过右键然后点击->Create来创建。

Thiswillallowyoutoaddscripts,Prefabs,orfolderstokeepyourprojectorganized.Youcanrenameanyasset/folderbypressingF2onWindows,orEnteronMac,orwithtwopacedclicksontheassetname.IfyouholdtheAltkeywhileyouexpandorcontractadirectory,allsubdirectorieswillalsobeexpandedorcontracted.

这将允许你添加脚本、预制组件(想不出更好的名字了)、或文件夹让您的项目组织有序。你可以在Windows系统中按F2键(Mac系统中为回车)重新命名任何资源/文件夹,或通过在资源名字上两次点击(不是双击)来重命名。如果你按住Alt键的同时,展开或收起一个目录,所有子目录也将展开或收起。

Hierarchy(层次结构视图)

TheHierarchycontainseveryGameObjectinthecurrentScene.Someofthesearedirectinstancesofassetfileslike3Dmodels,andothersareinstancesofPrefabs--customobjectsthatwillmakeupmuchofyourgame.YoucanselectandParentobjectsintheHierarchy.Asobjectsareaddedandremovedfromthescene,theywillappearanddisappearfromtheHierarchyaswell.

层次视图包含了每一个当前场景的游戏对象(GameObject)。其中一些是资源文件的实例,如3D模型和其他预制组件(完善你的游戏的自定义对象)的实例。您可以在层次结构视图中选择对象或者生成对象。当在场景中增加或者删除对象,层次结构视图中相应的对象则会出现或消失。

Parenting(父对象)

UnityusesaconceptcalledParenting.TomakeanyGameObjectthechildofanother,dragthedesiredchildontothedesiredparentintheHierarchy.Achildwillinheritthemovementandrotationofitsparent.YoucannowexpandandcontracttheparenttoseeitschildrenintheHierarchywithoutaffectingyourgame.

Unity使用父对象的概念。要想让一个游戏对象成为另一个的子对象,只需在层次视图中把它拖到另一个上即可。一个子对象将继承其父对象的动作和旋转属性。你在层次视图中展开和收起父对象,可以看到其子对象,而不会影响你的游戏。(这句翻译感觉有点别扭)

Twounparentedobjects(两个没有父对象的对象)

Oneobjectparentedtoanother(一个对象是另一个的父对象)

TolearnmoreaboutParenting,pleasereviewtheParentingsectionoftheTransformComponentpage.

要学习更多关于父对象的知识,请查看TransformComponentpage的关于父对象的部分。

Toolbar(工具条)

TheToolbarconsistsoffivebasiccontrols.EachrelatetodifferentpartsoftheEditor.

工具栏包括五个基本控制,每一个涉及到不同部分的编辑。

TransformTools--usedwiththeSceneView变换工具——用于场景视图

TransformGizmoToggles--affecttheSceneViewdisplay变换Gizmo(这个词是小物件、小玩意的意思,在这里不知道怎么翻译合适)开关——影响场景视图中的显示

Play/Pause/StepButtons--usedwiththeGameView运行/暂停/单步执行按钮——用于游戏视图

LayersDrop-down--controlswhichobjectsaredisplayedinSceneView层下拉菜单——控制场景视图中选中对象的显示

LayoutDrop-down--controlsarrangementofallViews布局下拉菜单——控制所有视图的排列

SceneView(场景视图)

TheSceneView(场景视图)

TheSceneViewisyourinteractivesandbox.YouwillusetheSceneViewtoselectandpositionenvironments,theplayer,thecamera,enemies,andallotherGameObjects.ManeuveringandmanipulatingobjectswithintheSceneViewaresomeofthemostimportantfunctionsinUnity,soit'simportanttobeabletodothemquickly.

场景视图是你的交互式沙箱(?)。你可以使用它来选择和布置环境、玩家、摄像机、敌人和所有其他游戏对象。在场景视图中调动和操作对象是Unity最重要的功能,因此,能够迅速掌握它们是非常重要的。

SceneViewNavigation(场景视图导航)

SeeSceneViewNavigationforfulldetailsonnavigatingthesceneview.Here'sabriefoverviewoftheessentials:

·HoldtherightmousebuttontoenterFlythroughmode.ThisturnsyourmouseandWASDkeys(plusQandEforupanddown)intoquickfirst-personviewnavigation.

·SelectanyGameObjectandpresstheFkey.ThiswillcentertheSceneViewandpivotpointontheselection.

·UsethearrowkeystomovearoundontheX/Zplane.

·HoldAltandclick-dragtoorbitthecameraaroundthecurrentpivotpoint.

·HoldAltandmiddleclick-dragtodragtheSceneViewcameraaround.

·HoldAltandrightclick-dragtozoomtheSceneView.Thisisthesameasscrollingwithyourmousewheel.

要查看场景视图导航的全部详细资料请点击SceneViewNavigation,下面是简要概述:

l按住鼠标右键进入飞行穿越模式。旋转你的鼠标且使用WASD键(Q向上、E向下)进入快速的第一人称视角导航。(这句翻译也别扭,能明白意思就行)

l选择任意游戏对象,然后按F键,所选择的物体将在场景视图的中心位置显示。

l使用方向键,将沿X/Z平面方向移动。

lALT+鼠标左键拖动使当前视野沿当前纵轴作圆周运动。

lALT+鼠标中键拖动可以拖动当前视野。

lALT+鼠标右键拖动可以缩放场景视野,这和你的鼠标滚轮作用相同。

YoumightalsofinduseintheHandTool(shortcut:Q),especiallyifyouareusingaone-buttonmouse.WiththeHandtoolisselected,也许你已经发现了手形工具(快捷键:Q),尤其是当你使用单键鼠标时,下面是各种选中状态的含义:

Click-dragtodragthecameraaround.在场景中拖动视野。

HoldAltandclick-dragtoorbitthecameraaroundthecurrentpivotpoint.ALT+鼠标左键拖动使当前视野沿当前纵轴作圆周运动。

HoldControl(CommandonMac)andclick-dragtozoomthecamera.按住CTRL(Mac系统中为Command键)+鼠标左键拖动缩放当前视野。

Intheupper-rightcorneroftheSceneViewistheSceneGizmo.ThisdisplaystheSceneCamera'scurrentorientation,andallowsyoutoquicklymodifytheviewingangle.

在场景视图右上角是场景小工具(SceneGizmo)。这里显示场景摄像机的当前方向,你可以快速地变换视角。

YoucanclickonanyofthearmstosnaptheSceneCameratothatdirectionandchangeittoIsometricMode.WhileinIsometricMode,youcanright-clickdragtoorbit,andAlt-clickdragtopan.Toexitthismode,clickthemiddleoftheSceneGizmo.YoucanalsoShift-clickthemiddleoftheSceneGizmoanytimetotoggleIsometricMode.

你可以点击任意方向杆从而使场景摄像机朝那个方向而且变为等轴(等距)模式。在等轴模式中,您可以鼠标右键拖动作圆周,也可以按住Alt键拖动来平移。按SceneGizmo的中心退出此模式。你还可以按住Shift键单击SceneGizmo的中心随时切换等轴模式。

PositioningGameObjects(定位游戏对象)

SeePositioningGameObjectsforfulldetailsonpositioningGameObjectsinthescene.Here'sabriefoverviewoftheessentials:查看详情请点击PositioningGameObjects,下面是概述:

Whenbuildingyourgames,you'llplacelotsofdifferentobjectsinyourgameworld.TodothisusetheTransformToolsintheToolbartoTranslate,Rotate,andScaleindividualGameObjects.EachhasacorrespondingGizmothatappearsaroundtheselectedGameObjectintheSceneView.YoucanusethemouseandmanipulateanyGizmoaxistoaltertheTransformComponentoftheGameObject,oryoucantypevaluesdirectlyintothenumberfieldsoftheTransformComponentintheInspector.

建立你的游戏时,你会在你的游戏世界中放置许多不同的对象。要做到这一点必须使用工具栏的变换工具来调动、旋转和按比例缩放个别游戏对象,每个在场景视图中选中的对象都有一个对应的Gizmo,你可以用鼠标操作Gizmo轴来改变游戏对象的转换组件,也可以在检视视图中为转换组件的各字段直接输入数字。

调动工具——快捷键“W”旋转工具——快捷键“E”缩放工具——快捷键“R”

SceneViewControlBar(场景视图控制条)

TheSceneViewcontrolbarletsyouseethesceneinvariousviewmodes-Textured,Wireframe,RGB,Overdraw,andmanyothers.Itwillalsoenableyoutosee(andhear)in-gamelighting,gameelements,andsoundintheSceneView.SeeViewModesforallthedetails.

场景视图控制条可以让你看到不同的视图模式——纹理模式,线框模式,RGB模式,透视模式,等等,它也可以让你看到(听到)游戏中的灯光、游戏要素、声音等。点击ViewModes查看视图模式的详情。

GameView(游戏视图)

TheGameViewisrenderedfromtheCamera(s)inyourgame.Itisrepresentativeofyourfinal,publishedgame.YouwillneedtouseoneormoreCamerastocontrolwhattheplayeractuallyseeswhentheyareplayingyourgame.FormoreinformationaboutCameras,pleaseviewtheCameraComponentpage.

游戏视图显示你最后发布游戏后的运行画面,你需要使用一个或多个摄像机来控制玩家在游戏时实际看到的画面。如需更多关于摄像机的信息,请查看CameraComponentpage。

PlayMode(运行模式)

UsethebuttonsintheToolbartocontroltheEditorPlayModeandseehowyourpublishedgamewillplay.WhileinPlaymode,anychangesyoumakearetemporary,andwillberesetwhenyouexitPlaymode.TheEditorUIwilldarkentoremindyouofthis.

使用工具条按钮控制运行模式来看看您发布的游戏如何运行。在运行模式下,任何更改都只是暂时的,它们将在退出运行模式时重置复位。提醒你一点,在运行模式下编辑界面会变暗。

GameViewControlBar(游戏视图控制条)

Thefirstdrop-downontheGameViewcontrolbaristheAspectDrop-down.Here,youcanforcetheaspectratiooftheGameViewwindowtodifferentvalues.Itcanbeusedtotesthowyourgamewilllookonmonitorswithdifferentaspectratios.

控制条的第一个下拉菜单是Aspect外观菜单,在这里,你可以强制游戏窗口为不同的长宽比,它可以用来测试游戏在不同长宽比的显示器中的不同情况。

FurthertotherightistheMaximizeonPlaytoggle.Whileenabled,theGameViewwillmaximizeitselfto100%ofyourEditorWindowforanicefull-screenpreviewwhenyouenterPlaymode.

再往右是最大化运行切换开关MaximizeonPlay,启用后,在你进入运行模式时将全屏幕最大化游戏。

ContinuingtotherightistheGizmostoggle.Whileenabled,allGizmosthatappearinSceneViewwillalsobedrawninGameView.ThisincludesGizmosdrawnusinganyoftheGizmosclassfunctions.

继续往右是Gizmos切换开关,启用后,所有在场景视图中出现的Gizmos也将出现在游戏视图画面中,这包括使用任意Gizmos类函数生成的Gizmos。(最后句话我也不确定是不是这个意思)

FinallywehavetheStatsbutton.ThisshowsRenderingStatisticswindowthatisveryusefulforOptimizingGraphicsPerformance.

最后是统计(状态)按钮,它将显示一些对优化显示性能非常有用的渲染统计状态数值。

GameViewStatsofyourgame.(游戏视图中的状态显示)

Inspector(检视视图)

GamesinUnityaremadeupofmultipleGameObjectsthatcontainmeshes,scripts,sounds,orothergraphicalelementslikeLights.TheInspectordisplaysdetailedinformationaboutyourcurrentlyselectedGameObject,includingallattachedComponentsandtheirproperties.Here,youmodifythefunctionalityofGameObjectsinyourscene.YoucanreadmoreabouttheGameObject-Componentrelationship,asitisveryimportanttounderstand.

Unity的游戏都是由包含网格、脚本、声音和其他图形元素(如光源)的多种游戏对象组成的,检视视图显示当前选定的游戏对象的所有附加组件及其属性的相关详细信息,在这里,您可以修改场景中的游戏对象的功能。你可以有关游戏对象组件的内容,因为它非常重要。

AnypropertythatisdisplayedintheInspectorcanbedirectlymodified.Evenscriptvariablescanbechangedwithoutmodifyingthescriptitself.YoucanusetheInspectortochangevariablesatruntimetoexperimentandfindthemagicgameplayforyourgame.Inascript,ifyoudefineapublicvariableofanobjecttype(likeGameObjectorTransform),youcandraganddropaGameObjectorPrefabintotheInspectortomaketheassignment.

任何在检视视图中显示的属性,都可以直接修改,即使是脚本变量也可以直接修改而无需修改脚本本身。你可以使用检视视图在游戏运行时更改变量来尝试这种奇妙的方式。在脚本中,如果你定义一个对象类型(如游戏对象或Transform属性)为公共变量,那么你可以在检视视图中通过拖放将它分配给一个游戏对象或预制组件。

ClickthequestionmarkbesideanyComponentnameintheInspectortoloaditsComponentReferencepage.PleaseviewtheComponentReferenceforacompleteanddetailedguidetoallofUnity'sComponents.

点击检视视图中任何组件名称旁边的问号将载入其组件参考页。请查看完整而详细的有关Unity所有组件的参考。

AddComponentsfromtheComponentmenu(通过组件菜单添加组件)

Youcanclickthetinygearicon(orright-clicktheComponentname)tobringupacontextmenuforthespecificComponent.

你也可点击小齿轮图标(或右键单击组件名称)弹出特定组件的相关菜单。

TheInspectorwillalsoshowanyImportSettingsforaselectedassetfile.

检视视图还将显示选定的资源文件的导入设置。

ClickApplytoreimportyourasset.(单击应用以重新导入你的资源)

UsetheLayerdrop-downtoassignarenderingLayertotheGameObject.UsetheTagdrop-downtoassignaTagtothisGameObject.

使用Layer下拉菜单为游戏对象指派渲染层。使用Tag下拉菜单为此游戏对象指派一个标签。

Prefabs(预制组件/预设件)

IfyouhaveaPrefabselected,someadditionalbuttonswillbeavailableintheInspector.FormoreinformationaboutPrefabs,pleaseviewthePrefabmanualpage.

如果你选择了一个预设件,检视视图中将出现一些额外的可用按钮。如需更多预设件信息,请查看Prefabmanualpage。

OtherViews(其它视图)

TheViewsdescribedonthispagecoversthebasicsoftheinterfaceinUnity.TheotherViewsinUnityaredescribedelsewhereonseparatepages:

这个页面中的视图描述涵盖了Unity界面的基本知识,Unity的其他视图描述在其他单独页面上:

·TheConsoleshowslogsofmessages,warnings,anderrors.——控制台显示关于消息、警告和错误的日志。

·TheAnimationViewcanbeusedtoanimateobjectsinthescene.——动画视图可以用来制作场景中的动画对象。

·TheProfilercanbeusedtoinvestigateandfindtheperformancebottle-necksinyourgame.——事件探查器可以用来研究和发现你的游戏的性能瓶颈。

·TheAssetServerViewcanbeusedtomanageversioncontroloftheprojectusingUnity'sAssetServer.——资源服务器视图可用于管理使用Unity资源服务器的项目的版本控制

·TheLightmappingViewcanbeusedtomanagelightmapsusingUnity'sbuilt-inlightmapping.——lightmapping视图可以用来管理使用Unity内置光照贴图的光照贴图(很别扭)

·TheOcclusionCullingViewcanbeusedtomanageOcclusionCullingforimprovedperformance.——遮挡剔除视图可以用来管理遮挡剔除以提高性能。(也很别扭)

最后这两句由于对专业术语不太了解,不知道翻译的是否准确。

如果觉得《Unity3D中文手册1》对你有帮助,请点赞、收藏,并留下你的观点哦!

本内容不代表本网观点和政治立场,如有侵犯你的权益请联系我们处理。
网友评论
网友评论仅供其表达个人看法,并不表明网站立场。