Adjust tint color of particles/additive?

Ive been all over google trying to figure out my error with no luck. i have a mesh renderer with a particle/additive material that i am trying to change the tint color of for a fade out. All works good but every now and then im getting the following error in the debugger. not sure how major of a problem it is as it doesnt seam to mess anything up… but lol would like to find a way to stop it if possible. any help would be greatly appreciated, thank you :slight_smile:

Material doesn’t have a color property ‘_Color’

UnityEngine.Material:get_color()

public void AttackGroundSlam () {
	GSTime -= Time.deltaTime;
	if (GSTime < .5f) {
		if (!gs) {
			gs = Instantiate (GS, transform.position, Quaternion.identity);
			gs.gameObject.tag = "GS";
			GSR = gs.GetComponent<MeshRenderer> ();

		}
		gs.transform.localScale += new Vector3 (1, 0, 1) * (Time.deltaTime*70);
		if (GSTime < .25) {
			
			float GSTransparency = Mathf.Round(100 * (GSTime / .25f));
			if (GSTransparency < 0) {
				GSTransparency = 0;
			}
			Debug.Log ("GSTransparency" + GSTransparency);
			GSR.material.SetColor("_TintColor", new Color(GSR.material.color.r,GSR.material.color.g,GSR.material.color.b,GSTransparency));
			if (GSTransparency <= 0) {
				AttackGSBool = false;
				Destroy (gs.gameObject);
			}
		}
	}
}

Hey @Galatia410 !
If you still need an answer for that (probably not because like almost a year passed since then but STILL), then the problem is probably that you wrote, in line 18, “new Color(GSR.material.color.r,GSR.material.color.g,GSR.material.color.b,GSTransparency)” - and what’s wrong here is that you wrote “material.color” altho this material has no color - it has TINT color.

To fix it, just write “material.GetColor(”_TintColor"); instead!

Hope it helps :smiley:
I know it because I ran into the same problem, after previously using this same code for other material that had normal color - and I saw your post several minutes before I understood the problem :smiley:

Dude! @Galatia410

You just made my day! I was unable to change the TintColor aspect, but thanks to your code it now works! Thanks a million!

Leeghart

ps: I do not know the answer to your question…I do not get the error messages