Gameplay in 2D
2D上的游戏
While famous for its 3D capabilities, Unity can also be used to create 2D games. The familiar functions of the editor are still available but with helpful additions to simplify 2D development.
虽然它以3D著称,Unity也可以被用于创建2D游戏.编辑器的常用功能依然可用但补充了些有助简化2D开发.
Scene viewed in 2D mode
2D模式场景视图
The most immediately noticeable feature is the 2D view mode button in the toolbar of the Scene view. When 2D mode is enabled, an orthographic (ie, perspective-free) view will be set; the camera looks along the Z axis with the Y axis increasing upwards. This allows you to visualise the scene and place 2D objects easily.
大部分显而易见的特性是2D视图模式按钮在场景视图上的工具条.当2D模式激活,一个正交(即,免除透视)模式将被设置.摄像机正对着Z轴而Y轴向上增长.这允许你方便的显现场景和放置2D对象.
For a full list of 2D components, how to switch between 2D and 3D mode, and the different 2D and 3D Mode settings, see 2D or 3D Projects.
一个完整的2D组件列表,如何在2D和3D模式间切换,2D和3D模式的不同,参考”2D或3D项目”.
2D Graphics
2D图形
Graphic objects in 2D are known as Sprites. Sprites are essentially just standard textures but there are special techniques for combining and managing sprite textures for efficiency and convenience during development. Unity provides a built-in Sprite Editor to let you extract sprite graphics from a larger image. This allows you to edit a number of component images within a single texture in your image editor. You could use this, for example, to keep the arms, legs and body of a character as separate elements within one image.
2D图形对象被称为精灵.精灵本质上仅是标准纹理但有些特殊技术在开发期间方便而有效的组合和管理精灵纹理.Unity提供一个内建的精灵编辑器以让你从一张大图抓取精灵图形.这允许你在你的图片编辑器上通过一张单个贴图上编辑许多组件图片.你可以使用这,如,保持角色的手臂,腿和身体作为分离的元素在一张图片内.
Sprites are rendered with a Sprite Renderer component rather than the Mesh Renderer used with 3D objects. You can add this to a GameObject via the Components menu (Component > Rendering > Sprite Renderer )or alternatively, you can just create a GameObject directly with a Sprite Renderer already attached (menu: GameObject > 2D Object > Sprite).
精灵使用精灵渲染器组件渲染而不是3D对象使用的网格渲染器.你可以给一个对象通过组件菜单添加它(组件>渲染>精灵渲染)或者,你可以仅直接创建一个游戏对象且已附加上精灵渲染器(菜单:游戏对象>2D对象>精灵).
In addition, you can use a Sprite Creator tool to make placeholder 2D images.
另外,你可以使用一个精灵创建器工具制作站位2D图片.
2D Physics
2D物理
Unity has a separate physics engine for handling 2D physics so as to make use of optimizations only available with 2D. The components correspond to the standard 3D physics components such as Rigidbody, Box Collider and Hinge Joint, but with “2D” appended to the name. So, sprites can be equipped with Rigidbody 2D, Box Collider 2D and Hinge Joint 2D. Most 2D physics components are simply “flattened” versions of the 3D equivalents (eg, Box Collider 2D is a square while Box Collider is a cube) but there are a few exceptions.
Unity有一个处理2D物理的单独的物理引擎以利于只适合在2D模式下的优化.与3D物理组件相似的组件如刚体,碰撞器盒子和枢纽关节,但添加了”2D”到名字上.因此,精灵可以装配刚体2D,碰撞器盒子2D和枢纽关节2D.大部分2D物理组件仅仅是”平面”版本的3D同等物(如,碰撞器2D是一个正方形而碰撞器是一个立方体)但也有些例外.
For a full list of 2D Physics components, see 2D or 3D Projects. See the Physics section of the manual for further information about 2D physics concepts and components.
2D物理组件完整列表,参考”2D或3D项目”.查看手册的”物理学”部分获取更多关于2D物理概念和组件的详细信息.