2D Toolkit Forum

2D Toolkit => Support => Topic started by: drkucho on March 01, 2015, 02:47:14 pm

Title: Multiple materials for all sprites in collection
Post by: drkucho on March 01, 2015, 02:47:14 pm
i have a shader that allows to replace colors , i have my sprite collection with a man in white for the player but i want the enemies to use the same sprite collection but with other colors,  created different materials with this shader using each one different colors, but if i set the material of the enemy , the player gets changed as well

any way to do this without having to duplicate the sprite collection?
Title: Re: Multiple materials for all sprites in collection
Post by: unikronsoftware on March 02, 2015, 02:47:55 pm
You can do that with a bit of code. You'll need a dictionary that maps a material to each sprite collection material, and hook into the SpriteChanged callback. Every time the sprite is changed, look up the newly assigned material, find your equivalent material and assign it.
Title: Re: Multiple materials for all sprites in collection
Post by: drkucho on March 24, 2015, 02:22:23 pm
it works, thank you very much! :)