playMaker

Author Topic: Set Material Color not resetting on exit  (Read 2811 times)

indeed

  • Junior Playmaker
  • **
  • Posts: 85
Set Material Color not resetting on exit
« on: July 22, 2016, 05:59:55 PM »
Hi, I need to control every instance a certain material is used. So, I dragged the material from the *project* window into the Set Material Color action. It works great when I play it, the only thing is that Unity remembers the color change/doesn't reset the color after exiting out of Play mode. Is this possible?

Gua

  • Beta Group
  • Sr. Member
  • *
  • Posts: 309
    • Andrii Vintsevych
Re: Set Material Color not resetting on exit
« Reply #1 on: May 30, 2017, 02:35:46 AM »
I have same question.

Fat Pug Studio

  • Beta Group
  • Hero Member
  • *
  • Posts: 1294
    • Fat Pug Studio
Re: Set Material Color not resetting on exit
« Reply #2 on: May 30, 2017, 07:22:51 AM »
Did you check "reset on exit"?
Available for Playmaker work

Gua

  • Beta Group
  • Sr. Member
  • *
  • Posts: 309
    • Andrii Vintsevych
Re: Set Material Color not resetting on exit
« Reply #3 on: May 31, 2017, 01:04:16 AM »
There is no "reset on exit" in set material color action. Also usually "reset on exit" resets values when playmaker leaves this state. We are talking about the fact, that material doesn't reset it's color, when we exit out of play mode. Every single value resets if it was changed during play mode, but not this one. Also it should affect only material instance on an object, but it changes color for material inside project.

It looks like a bug to me.

p.s. I'm using this action to change material color on Particle System. And if this is not the right way to do it, please tell me what is the correct way.

Deek

  • Full Member
  • ***
  • Posts: 133
Re: Set Material Color not resetting on exit
« Reply #4 on: May 31, 2017, 02:47:56 PM »
It's not a bug, it is how Unity works: Every GameObject that has a Material applied to it doesn't create an instance of that Material, but a reference to it. That's why you can't change the Material of certain GameObjects individually.
Much like Prefabs, if you change a value of a Material (like Color) at runtime, it applies that change to the (in this case .mat) file in the Assets-Folder.

In that Action, you also can't store the previous color and reapply that when leaving Play-Mode since it doesn't have control over it once you leave the State it's in.

Long story short - You can only do a work-around like (and that's what I always do, wich works flawlessly) resetting the default color in the Start-State or when the game starts.
So you just create another Set Material Color wich applies the default color (the one before you change it) in any early State where it's appropriate.

Gua

  • Beta Group
  • Sr. Member
  • *
  • Posts: 309
    • Andrii Vintsevych
Re: Set Material Color not resetting on exit
« Reply #5 on: July 01, 2021, 09:58:25 PM »
I was able to make modified version of this action with reset on exit option, that seems to work great. I wonder why it wasn't implemented there by default.

« Last Edit: July 01, 2021, 10:01:39 PM by Gua »

djaydino

  • Administrator
  • Hero Member
  • *****
  • Posts: 7616
    • jinxtergames
Re: Set Material Color not resetting on exit
« Reply #6 on: July 02, 2021, 09:19:03 AM »
Hi.
Just so you know, if you want to change color on a 'instance' of the material (on the object) and not the material it self.
Then you can use "Set Material Property Block Color" (Ecosystem)

So what deek explained is half true, you actually can change individually and this is not updated on the material itself,
So if you stop the game, the material is unchanged :)