- Home /
Fade GUI Textures when value changes C#
What I'm trying to accomplish: I'm trying to make 2 gradient images fade over one another when a value increases.
What I have: I currently have a list of values and locations (of where the labels/textures must be placed), so the only thing I'm trying to accomplish is to place a Blue gradient on the locations and make the Red fade in when the value increases.
Here's what I have so far:
for (int a = 0; a < _Positions.Count; a++){
Vector3 LabelPos = Camera.main.WorldToScreenPoint(_Positions[a]);
GUI.Label (new Rect(LabelPos.x, LabelPos.y, 100, 30), gameObject.GetComponent<myAudioAnalysis>().RMStodBFS(gameObject.GetComponent<myAudioAnalysis>().myMeanRMS[a]).ToString(), LabelDbStyle);
}
I added the following code, but the values I get from my$$anonymous$$eanR$$anonymous$$S are negative so the backgrounds of my labels just stay green. Anyone got any idea?
GUI.backgroundColor = new Color(gameObject.GetComponent<myAudioAnalysis>().R$$anonymous$$StodBFS(gameObject.GetComponent<myAudioAnalysis>().my$$anonymous$$eanR$$anonymous$$S[a]) * 2f, 1f - gameObject.GetComponent<myAudioAnalysis>().R$$anonymous$$StodBFS(gameObject.GetComponent<myAudioAnalysis>().my$$anonymous$$eanR$$anonymous$$S[a]) * 2f, 0f, 1f);
Your answer
Follow this Question
Related Questions
A node in a childnode? 1 Answer
Vector3 List Find Contains Specific X Coordinate Value and Remove 0 Answers
How to the tint alpha of a shader 1 Answer
Interchangeable value loop 1 Answer
Fog effect on shader 0 Answers