Project Setup
Once you have successfully created your project, make sure you have the following folders in your assets folder:
- Sources
- Materials
- Menu
- Prefabs
- Scenes
- Scripts
- Textures
These are the only folders you will need for this project. However, if you decide to expand it, you can add any other folders you see fit (sounds, animations, etc.)
Once you’ve created the above folders, go to File > Build Settings. In this window, click the Android option under the “Platforms” heading, then click “Switch Platform” in the bottom left corner. This will tell Unity that you are building for Android and will set up the project. You will need Android Studio installed for this to work. Then save the scene by pressing Ctrl+S or choosing “Save Scene” from the File menu. Save this scene as “Main Scene” in your “Scenes” folder.
Creating Particle Prefabs
Above is an image of a star with a black background. Save this image in your Textures folder. You’ll use it for the Particle System.
Set the Texture Type to Texture by clicking the image in your Textures folder and selecting the appropriate value in the Inspector, then clicking Apply. Make sure the “Alpha is transparency” box is checked. This will make the background of the star transparent.
Next, create a particle system and set it using the values shown in the screenshot above.
Feel free to modify these values if you wanted to; they are just guidelines. Playing around with these values will give you a better understanding of how it works.
Make sure the particle system texture is set to the star texture by expanding the Shader and selecting the star texture in the box on the right. Or you can drag and drop the image from your Textures folder into the box. Choose Mobile/Particle/Alpha Blended Shader by clicking the dropdown box next to Shader, then Mobile > Particles > Alpha Blended. This will tell the particle system to make the background of the star transparent and optimize it for Android. Change the name at the top of the Inspector to “Explosion” and do the same in the Hierarchy. Then drag this Explosion Particle System from the Hierarchy into your Prefabs folder in the Project view. This will create a prefab of that particle system.
Next, we’ll create a Trail Prefab, which will draw a trail whenever you drag your finger across the screen. The trail will disappear after a couple of seconds when you lift your finger.
Create a new empty game object (right click on the hierarchy and select “Create Empty”) and call it Trails or something similar. Then add a Trail Renderer component to it. Set it up using the values provided in the screenshot above.
Create a new material by clicking the Materials folder in the project view, then right-clicking in the project view and clicking in Create > Material. Name the material Trail Material or Trail Mat.
Then click the Trail Set Object in the Hierarchy and drag and drop the Trail Mat from the Project view to the Inspector window. This will assign the Material to the Trails Game Object. Next, drag this Trails game object into your prefabs folder to make it a prefab.
Finally, we’ll create another particle system that will be different from the first one. It will slowly explode outward, have no gravity, and slowly fade away. Create another Particle System and label it Pinch Blast (we’ll use a pinch gesture to initialize it). Make sure the star material is assigned to this particle system, and then make it a prefab.
These are all the effects we’ll be using. Feel free to create more if you like or modify existing ones; One last thing before we can move on to programming is to click on the main camera in the hierarchy. Change the Background Color to black or another dark color and change the Size (under the Projection dropdown box) from 5 to 10. This will allow you to see more of the background. Look at the last screenshot above if you are confused.
.