Author Topic: How to set color/alpha for multiple sprites at the same time  (Read 5919 times)

mtran003

  • Newbie
  • *
  • Thank You
  • -Given: 0
  • -Receive: 0
  • Posts: 11
    • View Profile
The is there an effective, performance optimized method of changing color tint and alpha setting of all the sprites that share the same atlas and texture at the same time?

I may have several hundred sprites that I would need to affect and looping over a sprite array does not seem effective--especially during frame Update where the value changes over time.

With regular Unity, I'm able to get a reference to the Material and the set the material's ".color.a" value at runtime.

Is there something similar for NGUI?

Ferazel

  • Full Member
  • ***
  • Thank You
  • -Given: 1
  • -Receive: 2
  • Posts: 150
    • View Profile
Re: How to set color/alpha for multiple sprites at the same time
« Reply #1 on: May 18, 2012, 01:42:34 PM »
You can use a different material/shader that uses a color component, but the same texture. This will then allow you to change the tint color of all of the elements that use that material at runtime by just changing that one material's color component. Having another material will cause your draw calls to increase if you have UIPanels that use multiple materials.

ArenMook

  • Administrator
  • Hero Member
  • *****
  • Thank You
  • -Given: 337
  • -Receive: 1171
  • Posts: 22,128
  • Toronto, Canada
    • View Profile
Re: How to set color/alpha for multiple sprites at the same time
« Reply #2 on: May 18, 2012, 05:04:40 PM »
Or you can just modify the shader, adding a color property.