2D Toolkit Forum
2D Toolkit => Support => Topic started by: zeteginara on August 14, 2014, 02:07:59 am
-
I made a color channel on my tilemap to make it look like nighttime. I have designed it so, when the scene loads, on start it checks to see if a flag exists, and if so, I want to programatically delete the color channel. Here's my code:
var channel = GameObject.Find("TileMap").GetComponent<tk2dTileMap>().ColorChannel;
channel.Delete();
GameObject.Find("TileMap").GetComponent<tk2dTileMap>().Build();
I've also tried:
var channel = GameObject.Find("TileMap").GetComponent<tk2dTileMap>().ColorChannel;
channel.Clear(Color.white);
GameObject.Find("TileMap").GetComponent<tk2dTileMap>().Build();
Neither of them get rid of the color channel, it stays 'nighttime'. What am I doing wrong?
-
Have you tried calling
GameObject.Find("TileMap").GetComponent<tk2dTileMap>().DeleteColorChannel();
followed by
GameObject.Find("TileMap").GetComponent<tk2dTileMap>().ForceBuild();
This isn't a great way to do it as its really quite slow. A better option would be to change the shader on your material to one that doesn't use vertex colors. That will be instant.
-
I'm currently using the tk2d/CutoutVertexCoor shader because of this:
http://2dtoolkit.com/forum/index.php/topic,3981.msg19046.html#msg19046
Does that suffice? If so, how do I make it instant?
Also, is there any way to lerp the color? I want the color channel to be able to transition to clear, to represent sunrise, etc.
-
Are you fililng the whole color thing with one color? If so just use one of the unity built in shaders that have a color parameter, you can simply change that to tint the whole screen, transitions will be close to free.
You will need to find a cutout shader that has a color parameter if you need to use cutout, or create one yourself.