mob-sakai / UIEffect

UIEffect is an effect component for uGUI element in Unity. Let's decorate your UI with effects!
https://github.com/mob-sakai/UIEffect
MIT License
5.73k stars 787 forks source link

Sprite destruction effect #100

Open buihuuloc opened 6 years ago

buihuuloc commented 6 years ago

Hi @mob-sakai Have you ever think about this effect?

mob-sakai commented 6 years ago

Hi @buihuuloc

What is "destruction effect"? Do you have any images or videos of examples?

buihuuloc commented 6 years ago

Hi You can check this open source. https://github.com/mjholtzem/Unity-2D-Destruction

mob-sakai commented 6 years ago

Hmm...

The effect is so cool, but not for UI. It probably can be implemented for UI, but there are some disadvantages.

mob-sakai commented 6 years ago

In this effect, Physics moves UI elements (with Rigidbody component). When the UI element moves, Canvas rebuilds the layout with overhead.

mob-sakai commented 6 years ago

When dividing the mesh, it needs to be rendered as each mesh. It would be difficult to use other effects (such as UIShadow) together.

mob-sakai commented 6 years ago

When implementing for UI, the compromise is as follows.

  1. Can not use with Physics
  2. Can not use with other effects
buihuuloc commented 6 years ago
mob-sakai commented 6 years ago

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.

  1. UIExplosion.MeshModify: UI elements are divided into multiple polygons and converted to mesh
  2. Set mesh with CanvasRenderer.SetMesh
  3. 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.