UIEffect
UIEffect copied to clipboard
Sprite destruction effect
Hi @mob-sakai Have you ever think about this effect?
Hi @buihuuloc
What is "destruction effect"? Do you have any images or videos of examples?
Hi You can check this open source. https://github.com/mjholtzem/Unity-2D-Destruction
Hmm...
The effect is so cool, but not for UI. It probably can be implemented for UI, but there are some disadvantages.
In this effect, Physics moves UI elements (with Rigidbody component). When the UI element moves, Canvas rebuilds the layout with overhead.
When dividing the mesh, it needs to be rendered as each mesh. It would be difficult to use other effects (such as UIShadow) together.
When implementing for UI, the compromise is as follows.
- Can not use with Physics
- Can not use with other effects
- Agree with you that It doesn't need to be used with Physics.
- The Canvas rebuilds issue. I think this effect is for special cases, so It can have its own canvas.
- For the motion: I think It can have a basic movement and can be extended
I see.
It can be implemented like a particle system. That is, the "particle" data array and the simulation function update the mesh. There is only one game object, component and renderer.
Implement the UIExplosion component as follows.
- UIExplosion.MeshModify: UI elements are divided into multiple polygons and converted to mesh
- Set mesh with CanvasRenderer.SetMesh
- The simulation function updates the mesh according to "particle" data array and elapsed time
The nice thing about this implementation is "Canvas will not rebuild." Also, you do not need a shader, you can use it with other effects.