Hello Guest

Author Topic: Multiple materials for all sprites in collection  (Read 4385 times)

drkucho

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 72
  • Retro Arcade Freak
    • View Profile
    • Dr. Kucho!
Multiple materials for all sprites in collection
« 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?

unikronsoftware

  • Administrator
  • Hero Member
  • *****
  • Posts: 9709
    • View Profile
Re: Multiple materials for all sprites in collection
« Reply #1 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.

drkucho

  • 2D Toolkit
  • Jr. Member
  • *
  • Posts: 72
  • Retro Arcade Freak
    • View Profile
    • Dr. Kucho!
Re: Multiple materials for all sprites in collection
« Reply #2 on: March 24, 2015, 02:22:23 pm »
it works, thank you very much! :)