Tasharen Entertainment Forum

Support => NGUI 3 Support => Topic started by: hungweng on May 30, 2013, 01:34:46 AM

Title: Change Shader Property
Post by: hungweng on May 30, 2013, 01:34:46 AM
Hi,

    I have some properties on the material used by the Sprite that I would like to change by code, but I am not sure where to get the material used by the sprite.
    The sprite.material returns the sharedMaterial but that would change all the sprite used by the same material which is not what I want.
    How should i implement this?
Title: Re: Change Shader Property
Post by: ArenMook on May 30, 2013, 03:01:56 PM
You can't modify materials per-sprite. There is only one material -- on the atlas. That's how everything is able to get batched into one draw call.
Title: Re: Change Shader Property
Post by: hungweng on May 30, 2013, 09:33:44 PM
Thanks ArenMook

What I have is a HSV shader that can do the Hue shifting, and the UISprite is actually a spriteAnimation using an atlas on its own.
Instead of having the artist to produce different textures for different color variation of the sprites, I thought I can save the product size by using the shader

So I guess if I really need to use different materials I'll have to duplicate both the UIAtlas prefab and the material in the editor and create sprites using the duplicated atlas...
I know it's going to have an extra drawcall but currently the drawcall is still very low so I guess it won't affect the performance for our game...at least not much
Title: Re: Change Shader Property
Post by: galuodo on May 31, 2013, 12:02:14 AM
I have an alternative solution, and now is optimizing. :)
Title: Re: Change Shader Property
Post by: hungweng on June 02, 2013, 08:50:51 PM
Hello Galuodo,

    Is it possible to share the alternative solution of yours or perhaps some hints please? Thanks!
Title: Re: Change Shader Property
Post by: galuodo on June 02, 2013, 09:20:35 PM
use UITexture