Unity 2D Termination Manual (1)-2D project + elf _unity3d Development _ Blue Gull
This article series mainly introduces Unity 2D Development technology. This includes The difference between the 2d/3d project, how to set up the 2d/3d mode, the components used in 2D development, and so on.
Unity is not only capable of creating cool 3D games, but also creating the perfect 2D game. When you use Unity to develop 2D content, most of the functionality of the editor is generic, but some features have been tweaked to simplify 2D development.
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M01/86/40/wKioL1e6XTfBmVsvAAvHd8hXQlI482.png-wh_500x0-wm_3 -wmp_4-s_3123825667.png "title=" Unity 2D Development (1) 2D3D project 357.png "alt=" Wkiol1e6xtfbmvsvaavhd8hxqli482.png-wh_50 "/>
(Figure 1) Unity 2D game
in theScenein the toolbar above the view, there is an obvious2Dmode button, click the button to2d/3dmode to switch between modes. When you open2Dmode, the scene is displayed in an orthographic view (3Dmode is displayed in Perspective view), at which pointSceneThe view's perspective appears to be towardZThe axis is in the positive direction and upward isYaxis positive direction. In this mode, we can easily set the2Dscenes, Operations2Dobject.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/86/40/wKiom1e6XnvDLoJHAAnSGVPoqWg858.png-wh_500x0-wm_3 -wmp_4-s_4252522987.png "title=" Unity 2D Development (1) 2D3D project 713.png "alt=" Wkiom1e6xnvdlojhaansgvpoqwg858.png-wh_50 "/>
Scene view in 2D mode (Figure 2)
when we create a new project, we can choose toThemode is still3Dmode starts. 2d/3dmode determines theUnitysome of the settings of the editor, such as when importing a picture, will default to it asTexture(texture) orSprite(Sprite). It doesn't matter if we accidentally choose the wrong pattern, and after the project is created, we can still2d/3dSwitch between modes. If we are not sure that our project should be2Dmode is also based on3Dpattern begins, we should first understand2d/3dthe difference between items.
One, completely 3D of the project
3D games typically use three-dimensional geometric models, using materials (Material) and rendering Textures(Texture) (render on the surface of these models, make them look like a house, character, or other object, and then form the entire game world. The camera can move freely around the scene, with realistic light and shadow projected throughout the game world. 3D Game rendering needs to be calculated from the perspective, so that the closer to the camera's object, the greater the display on the screen. Games that meet these descriptions should be developed in 3D mode.
650) this.width=650; "Src=" Http://s4.51cto.com/wyfs02/M02/86/40/wKiom1e6XreCmqQdAAvHd54ib2Q565.png-wh_500x0-wm_3 -wmp_4-s_1745918212.png "title=" Unity 2D Development (1) 2D3D project 1327.png "alt=" Wkiom1e6xrecmqqdaavhd54ib2q565.png-wh_50 "/>
(Fig . 3) Some completely 3D scenes
Second, orthogonal 3D project
sometimes a three-dimensional geometric model is used in the game, but the camera is an orthographic camera, not a perspective camera. This is a commonly used technology in game development, usually in the form of " aerial view " of the entire scene, we also call it "2.5D". If we need to develop such a game, we should also choose 3D mode, because even though the entire picture does not look like a perspective, we still need to use 3D models and resources. However, you need to adjust the camera and scene view to orthogonal.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/86/40/wKioL1e6XsyCDsnpAAqATfGRuNw203.png-wh_500x0-wm_3 -wmp_4-s_606297333.png "title=" Unity 2D Development (1) 2D3D project 1691.png "alt=" Wkiol1e6xsycdsnpaaqatfgrunw203.png-wh_50 "/>
(Fig . 4) Some 3D games with orthogonal views
Three, complete 2D project
many 2D games use flat graphics, also known as sprites(sprites). They are not stereoscopic, they are directly drawn on the screen, and the camera in the game does not have a sense of perspective. For this type of project, we should choose to start in 2D mode.
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M00/86/40/wKiom1e6XuWQ7aTQAAvHd8hXQlI722.png-wh_500x0-wm_3 -wmp_4-s_846888561.png "title=" Unity 2D Development (1) 2D3D project 1988.png "alt=" Wkiom1e6xuwq7atqaavhd8hxqli722.png-wh_50 "/>
(Fig . 5) Some completely 2D games
Iv. using 2D gameplay but with a 3D graphics project
in some games the three-dimensional model was used, but the game was limited to two dimensions, only 2D play. For example, the game uses 3D Models of obstacles, people, scenes, cameras are also perspective cameras, but the camera can always provide a horizontal scrolling view, the player can only manipulate the characters in two dimensions of movement. For these games,3D can only be considered a style, not the function of the game. This game can also be called "2.5D". Since we need to use the 3D model in the development process , this kind of game also needs to choose 3D mode.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M01/86/40/wKioL1e6XvuyhKXPAAsn5GHwU_Q419.png-wh_500x0-wm_3 -wmp_4-s_2568051206.png "title=" Unity 2D Development (1) 2D3D project 2399.png "alt=" Wkiol1e6xvuyhkxpaasn5ghwu_q419.png-wh_50 "/>
(Figure 6) A 2D horizontal board game, but with a 3D graphic effect
v. Use 2D graphics and gameplay, but include perspective camera items
This is also a common style of 2D games, using 2D Images but using a perspective camera. In this project, all the images are flat, but the distance from the camera is different, when the camera moves will produce a parallax scrolling effect, a more hierarchical sense. We were able to develop in 2D mode, just to set the Scene view to 3D, and adjust the camera to a perspective camera.
650) this.width=650; "Src=" Http://s1.51cto.com/wyfs02/M02/86/40/wKioL1e6Xy2BlaEZAAuJAzPg_3Y196.png-wh_500x0-wm_3 -wmp_4-s_3224353602.png "title=" Unity 2D Development (1) 2D3D project 2769.png "alt=" Wkiol1e6xy2blaezaaujazpg_3y196.png-wh_50 "/>
(Figure 7) a completely 2D game, but using a perspective camera
Vi. Other types of projects
your project may be one of these types, or you might want to create a completely different style of project, refer to the common types mentioned above, and remember that the 2d/3d pattern can be modified at any time during the project development process.
Unity 2D Termination Manual (2)-elves
all the images in 2D we call them Sprites (sprite) . Sprites are almost the same as standard textures, but special techniques are used to combine and manage sprite textures, thus improving development efficiency and making operations easier. Unity provides a built-in Wizard editor to extract sprite images from a large picture. This allows us to use an external graphical editor, such as Photoshop, to edit multiple image components in a single texture. For example, we can put the character's arms, legs, body and so on as a separate image element, stored in a large picture.
the 2D Sprite object needs to be used Genie Renderer (sprite Renderer)Instead of using the 3D object's Mesh renderer (mesh Renderer). We can use the Component menu (Component, Rendering, Sprite RendererAdd a Sprite renderer to the game object, or create a game object with a Sprite renderer directly (Gameobject, 2D Object, Sprite), we call it the Elf object. In addition, we can create tools through the wizard to make placeholder Sprite (Placeholder Sprite).
Related Tools
in Unity, a series of tools for sprite operations are provided to simplify our workflow. Include Genie Creator (sprite Creator),Sprite Editor, Genie Packager (sprite Packer)and the Genie Renderer (sprite Renderer).
Wizard Creator ( Sprite Creator) allows us to create a placeholder Sprite (Placeholder sprite)in Unity, So even if the art has not provided us with the image material, we can develop first.
we can use Sprite Editor extract the sprite image from a large image, or edit the image component in a texture, such as arms, legs, etc.
The Sprite object must pass the Genie Renderer (sprite Renderer) rendering can be displayed in the scene.
using in Projects Genie Packager (sprite Packer) ability to optimize the use and performance of video memory.
Import and set up sprites
in Unity, sprites are also a resource, and we can see them in Project view . There are two ways to introduce sprites:
1, in Span style= "font-family: ' Microsoft Jacob Black '; font-size:16px;" >finder (Mac OS) or file Explorer ( Windows) Unity's
2, from Asset, Import New Asset to select an image resource to import.
Next we need to set the imported image resource to Sprite. If our project pattern is Zero, then the import image resource will be automatically recognized as a sprite. If our project pattern is 3D, after the import defaults to texture (Texture), we need to change its texture type (Texture type) :
view ( Inspector View) import settings ( Import Setting)
2, will Texture Type (Texture type) property is changed to Sprite (2D and UI) .
650) this.width=650; "Src=" Http://s2.51cto.com/wyfs02/M02/86/40/wKioL1e6X4_S1n6pAAcWv7mCNdc248.png-wh_500x0-wm_3 -wmp_4-s_3079084837.png "title=" Unity 2D End Manual (2)-Genie 1422.png "alt=" Wkiol1e6x4_s1n6paacwv7mcndc248.png-wh_50 "/>
(Figure 1) Change the texture type to sprite in import settings
Unity 2D Termination Manual (1) (2)-2D project + elf _unity3d Development