2D Toolkit Forum
2D Toolkit => Support => Topic started by: DahongPunyal on February 03, 2014, 03:53:59 am
-
Is it possible for a tk2dSprite to change its shader at runtime?
Thanks!
-
it is possible, but you'll have to create a copy of the material yourself. The next time the sprite is changed it will reapply the original material, so you will need to manage that yourself. You can use the SpriteChanged event to deal with that.
-
Thanks for the reply.
Can you give me a code snippet for that?
I can't find the SpriteChanged event, maybe because I'm using an older version of tk2d?
-
I found a way to do this. I'm changing the sprite's renderer shader to other shader and it works fine. Thanks! We can close this now.
-
Sorry, I thought we can close this thread now. But, I tried to load it on iPad Mini and it didn't work. All I can see are pink assets. :(
-
You probably didn't put the shader in resources, or the shader isn't supported.
-
Meaning, I have to import tk2d's shaders to the resources folder for it to work? Thanks!
-
It implies your shader is likely null when you assign it. I don't know how you get the shader to swap it - you need to check that its not null and if it is, work out why.