Sprite Manager for 2D game
Generally Unity3D is not the best choice for developing 2D games. But as an engine can easily build games to different platforms, Unity is still a reasonable option under certain situation. Normal setup for 2D games will be setting up an orthographic camera and use planes as objects in the world. It has two main drawbacks:
- Since each objects(planes) needs its texture file, your game will end up loading too many texture files as a simple 2D game.
- Unity3D need to do 3D calculation and render all objects(planes) in the scene, which is a large overhead in performance.
These two drawbacks become significant when the game is running on mobile device, both for memory consumption and performance.
So you may considering using Sprite Manager to handle this kind of 2D games. You organize your textures into sprite sheet, and tell Sprite Manager which portion to render for each object. Also the game object you created does not have renderer, instead Sprite Manager will create its own mesh according to your objects' positions. It solves the two problems above, and makes your game lighter and faster.
Sprite Manager do have cons. Since your object does not need to have renderer. You can hardly build up levels in Unity Editor. So it is recommended you build up your game in the normal way, and switch to Sprite Manager for the final build. But please keep this in mind at the beginning, and design appropriate structure so you can easily switch back and forth.
Sprite Manager is a plugin for Unity3D. You can find its code and documentation on Unify Community.
The page should contain most information you need. Make sure you went through it. You can also find tutorials for Sprite Manager on youtube.
Here we just talk about one trick:
- For SpriteManager script, remember to change Winding value to CW, so the sprite you created will face the camera (-Z axis). Otherwise it will face +Z axis and you cannot see it unless you change the camera direction.
Here we provide a example project to show some basic use of Sprite Manager.
You can left click to drop dots and press SPACE to switch color.