Hello Guest

Author Topic: Shader can't be changed on PNG Atlas Sprite  (Read 3219 times)

David Kalina

  • 2D Toolkit
  • Newbie
  • *
  • Posts: 26
    • View Profile
Shader can't be changed on PNG Atlas Sprite
« on: March 03, 2014, 06:38:33 pm »
Repro case:

1.  Build a sprite collection with Atlas Format = PNG.
2.  Add sprite to level.
3.  Change sprite's shader to anything else.
4.  Run the game.  Sprite shader will reset to its default, which is undesired behavior.

Workaround:  change sprite collection to Unity Texture format, rebuild, change atlas material, change sprite collection back to PNG atlas.

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Shader can't be changed on PNG Atlas Sprite
« Reply #1 on: March 03, 2014, 11:54:12 pm »
That is intentional behaviour. The material on the sprite is transient when its a png, or when its dynamically loaded for platforms  and is managed by tk2d. It gets destroyed and recreated when the game starts. If you want to change the shader, change it on the actual material itself, or write a script to change it when the sprite changes (you can have multiple shaders within a collection, etc - you will need to cater for the features you use). You can use tk2dBaseSprite.SpriteChanged for notification when this happens.