- Home /
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 :)
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);
}
}
}
}
Answer by thetruesthfan · Aug 02, 2018 at 05:10 PM
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 :D 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 :D
Answer by wllmdhn · Mar 21, 2018 at 11:11 PM
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
Your answer
Follow this Question
Related Questions
Changing two different objects renderer colour 1 Answer
Material doesn't have a color property '_Color' 4 Answers
Does Material.color, ParticleSystem.startcolor property clones/copies the material? 2 Answers
How Do I Partially Change The Material of An Object On Collision? 1 Answer
MeshRenderer.material.color not changing inside if statement but is outside if statement? 1 Answer