playMaker

Author Topic: Material Compare Always False Because of (Instance) in Material Name?  (Read 1123 times)

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
I create a prefab and set its material to Material A. Then on the next operation (another right-click) it checks if the material is Material A. If so, it's supposed to Cycle to Material B, C, etc. But it always returns false. Here is a picture of it.

Notice how the game object's material is Material A (Instance), and the one compared for is Material A. What's the deal with this? Does this mean every time I'm creating prefabs it's adding more draw calls by duplicating materials? How do I fix this?

PS. It would be handy to have a Material Switch action, to avoid having a state with multiple Material Compare actions.

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Material Compare Always False Because of (Instance) in Material Name?
« Reply #1 on: August 29, 2018, 12:19:46 PM »
Hi.
Maybe you can use 'Get Material Name' and compare that?
Or use a string switch.

westingtyler

  • Sr. Member
  • ****
  • Posts: 277
    • My Video Game Projects Web Site
Re: Material Compare Always False Because of (Instance) in Material Name?
« Reply #2 on: September 02, 2018, 11:03:53 AM »
If it's creating material instances, doesn't that add draw calls? This would suck if the player needs to create dozens of the same object. Isn't there a way to cause it to use the same material rather than creating an instance?

I traced this to the Set Material action. It never uses the same material, but an instance, which also makes it difficult to later edit the core material since it seems to no longer reference the original material? is that right? Even if the material has GPU instancing disabled, it still creates this instance.
« Last Edit: September 02, 2018, 11:13:23 AM by westingtyler »