tailieunhanh - Ebook Learn unity for 2D game development: Part 2
Part 2 of ebook "Learn unity for 2D game development" include content: UVs and animation, cameras and pixel perfection, input for 2D games, getting started with a 2D game, completing the 2D card game, optimization, wrapping things up. Inviting you to refer. | Chapter UVs and Animation The previous chapter explained how to develop a GUI editor add-in that allows users to add selected textures in the project panel to a larger atlas texture. Atlas Textures help us improve the performance of our 2D games. In generating the atlas we also saved meta-data. This included all filenames of textures inside the atlas and their UV positions within the atlas. In closing that chapter we tested the add-on functionality by assigning an Atlas Texture to a procedural Quad Mesh in the scene to see how it looked in the Viewport. The problem we faced was that the quad mesh rendered the complete atlas texture rather than just a region of it see Figure 7-1 . The problem was not with the Atlas Texture but with the mesh itself with its UV mapping. By default the UV mapping for Quad Meshes is configured to show a complete texture. To show only a region the UV mapping must be adjusted at the vertex level. That is we must dig deeper into the mesh construction and edit its vertices. We ll do that in this chapter as we create a new editor add-in to control mesh UV mapping. This add-on lets us select a textured quad in the scene and entirely customize its UV mapping to show any region within the Atlas Texture or within any texture . In addition we ll also create another class to change UV mapping over time creating a flipbook animation effect or an animated sprite effect. 139 140 CHAPTER 7 UVs and Animation Figure 7-1. By default textured quads are generated with UV mapping to show a complete texture from the top-left corner to the bottom-right corner. This does not meet the needs of Atlas Textures. To fix this we ll need to edit the mesh UV mapping Creating a Dockable Editor So far in this book we ve built three editor add-ons if you ve been following every chapter a Batch Rename tool a Create Quad tool and a Create Atlas Texture tool. Despite the enormous differences in behavior between these tools they still have an important characteristic in .
đang nạp các trang xem trước