Author Topic: Particles with NGUI  (Read 3606 times)

Tatanan

  • Jr. Member
  • **
  • Thank You
  • -Given: 11
  • -Receive: 0
  • Posts: 81
    • View Profile
    • Casual Arena
Particles with NGUI
« on: July 02, 2015, 10:05:32 AM »
  • Does NGUI have his own particles system?
  • Is it possible and enough to use the Unity particle system itself without having problems with NGUI?

Basically I want to make the standard animation of giving many coins in a rewards with particles and looking for the best way, since I'm making all the (2D) game with NGUI.
Game developer on Casual Arena.

BeShifty

  • Jr. Member
  • **
  • Thank You
  • -Given: 5
  • -Receive: 7
  • Posts: 52
    • View Profile
Re: Particles with NGUI
« Reply #1 on: July 02, 2015, 03:50:50 PM »
I'm not at liberty to open source my solution, but here's the gist:

The goal is to have NGUI manage the draw order of the material that the particle system uses. The easiest way I found to do this was to create my own widget type/subclass, which overrides the material property, returning the particles system's desired material. NGUI will now manage the creation of an instance of that material with the correct render queue set, and all I have to do is assign the widget's drawCall.dynamicMaterial to the particle system renderer (usually in update since it could change).

Of course the devil's in the details, but that should get you going. Once that's set up, you can extend it to general Renderers like MeshRenderer and LineRenderer (or in my case, start general), and add soft clipping support (which has to work in world space instead of panel-space).

Good luck!

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile