UIEffect icon indicating copy to clipboard operation
UIEffect copied to clipboard

Sprite destruction effect

Open buihuuloc opened this issue 5 years ago • 8 comments

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

buihuuloc avatar Jul 18 '18 03:07 buihuuloc

Hi @buihuuloc

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

mob-sakai avatar Jul 18 '18 07:07 mob-sakai

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

buihuuloc avatar Jul 18 '18 10:07 buihuuloc

Hmm...

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

mob-sakai avatar Jul 18 '18 11:07 mob-sakai

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

mob-sakai avatar Jul 18 '18 11:07 mob-sakai

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 avatar Jul 18 '18 11:07 mob-sakai

When implementing for UI, the compromise is as follows.

  1. Can not use with Physics
  2. Can not use with other effects

mob-sakai avatar Jul 18 '18 11:07 mob-sakai

  • 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

buihuuloc avatar Jul 18 '18 12:07 buihuuloc

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.

mob-sakai avatar Jul 18 '18 16:07 mob-sakai