Acces shader color and lerp
Hello there! I want to acces the color "EmisColor" from the mobile/particles/vertexlit Blended shader. I can easly change the color by doing this
grid65.SetColor("_EmisColor",black);
//"black" is a public color varible
but what I really want to do is to lerp from the current color to the black one by doing this
grid65.SetColor("_EmisColor") = Color.Lerp(grid65.color,black,5*Time.deltaTime);
With gives me this error "The left-hand side of an assignment must be a variable, a property or an indexer" What Im doing wrong?
Answer by giorashc · Mar 20, 2016 at 04:31 PM
SetColor returns void and assigning a value to it has no meaning (hence the error).
You should use it as :
Color lerpedColor = Color.Lerp(grid65.color,black,5*Time.deltaTime);
grid65.SetColor("_EmisColor", lerpedColor);
That didnt work but however it pushed me in the right direction! Here is the final code
Color lerpedColor1 = Color.Lerp(grid64.GetColor("_EmisColor"),black,fadeSpeed*Time.deltaTime); grid64.SetColor("_EmisColor", lerpedColor1);
Your answer
Follow this Question
Related Questions
How to lerp through colors for a sprite? 1 Answer
Solid color texture or adding a color property to shader? 1 Answer
Black Image with custom material in "Game" when color is displayed in "Scene" 0 Answers
GameObject Color is visible on editor but not in Android when build 1 Answer
Get real colors like white or black 1 Answer