2D Toolkit Forum
2D Toolkit => Support => Topic started by: spudubi on January 16, 2014, 11:17:12 am
-
Hi,
My Sprite Collection uses a material with the 2dTk "BlendVertexColor" shader. I'm creating sprites from that collection at runtime like this:
tk2dSpriteCollectionData spriteCollection = Resources.Load("HexTilesData", typeof(tk2dSpriteCollectionData)) as tk2dSpriteCollectionData;
tk2dSprite tileSprite = tk2dSprite.AddComponent(goTemp,spriteCollection, "hexBorder");
Now I'm trying to change the shader of one sprite at runtime to the 2dTk shader "AdditiveVertexColor" like this:
selectedHexTile.sprite.renderer.material.shader = Shader.Find("AdditiveVertexColor");
But it doesn't work. The Sprite will be rendered in solid pink :). I guess that's because Unity can't find the "AdditiveVertexColor" shader. I tried to put the shader in a Resources folder but that didn't worked either.
What is the right way to change the shader?
-
1. it needs to be in resources
2. the name is "tk2d/AdditiveVertexColor"
-
Wow, thanks for your fast reply!
Now it works!
Is this method the best method (performance wise) to change the render style of a sprite to additive rendering during runtime?
-
Probably? There aren't any other ways of changing to additive when rendering as far as I can tell.