Prefabs can be reused in the game with just drugging it into "Hierarchy". Here I will show how to make a sprite prefab for Unity.
1. Create a Sprite:
3. Choose the image imported in the "assets" then change the "texture type" to "Sprite(2D\uGUI)":
Some times we also need to use sprite sheet to implement animation like explosion. Here are the steps to make that.
1. Choose the explosion image, change its texture type into Sprite and also modify its Sprite Mode to "Multiple":
2. Click "Sprite Editor" and slice the sprite sheet:
3. Create a Sprite and name it as "explosion". Add the material to "explosion":
4. Click "Window"-> "Animation"->"Add Curve"->"Sprite Renderer"->"Sprite":
5. Drag the other slices into the Animation Editor:
6. Modify the animation attributes as the images shows:
7. Play and we will see the animation. However, when the animation finishes playing, the object stays at the last image. We want to delete the object, so we need to modify the animation.
- Add a script to the object:
- Add an event on the animation and choose the function:
8. Run the game and after animation completes, the object is destroyed.
No comments:
Post a Comment