- Home /
Question by
Trorlroprlro · Nov 28, 2013 at 06:13 AM ·
colorrenderer
renderer.color.a +=
I'm having a problem with this:
if(anotherScript.isHurt == true)
{
Color color = renderer.material.color;
color.a += 0.01f;
}else
{
Color color = renderer.material.color;
color.a -= 0.01f;
}
Instead of slowly fading the screen black and out it doesnt do anything. I've attached a plane on the screen:
var bloodObject = GameObject.Find("bloodObject");
if(bloodObject)
{
bloodRenderer = bloodObject.renderer;
bloodRenderer.material.color = new Color(0.0f, 0.0f, 0.0f, 0.0f);
}
else
{
Debug.LogWarning("Not found");
}
Comment
Answer by ZouBi27 · Nov 28, 2013 at 07:03 AM
You need to reassign the color to the material.
Color color = renderer.material.color;
color.a += 0.01f;
renderer.material.color = color;
Your answer
Follow this Question
Related Questions
Changing two different objects renderer colour 1 Answer
Need material.color to revert. 3 Answers
Does Material.color, ParticleSystem.startcolor property clones/copies the material? 2 Answers
Changing the color at runtime is causing my material to look very different. 1 Answer
Pixel perfect in 3D -> Overlapping areas have mixed colors 1 Answer