Different >Colos OnGUI

Hi,

how can i set different colors with different values?

GUI.Label(new Rect(100,100,80,20), heartRate.ToString(),LapStyle);

if heartRate >= 0 <= 79 color red
if heartRate >= 80 <=119 color yellow
If heartRate >= 120 <= 150 color green
If heartRate >= 151 <= 170 color orange
If heartRate >= 181 color red

Use GUI.color = someColor. Don’t forget to set GUI.color = Color.white at the end or your GUI will be tinted.

Do you need to use OnGUI? 4.6 is pretty cool.

1 Like

hmm i have to disable the “GUIStyle” !?

i use 4.5.3 f3

I try to do something like this:

using UnityEngine;
using System.Collections;

public class heartrate : MonoBehaviour {

Color[] heart_colors = { Color.black, Color.blue, Color.cyan, Color.gray, Color.green, Color.red, Color.magenta, Color.white, Color.yellow, new Color (255,0,0,255) };   
int heartrateC = 50;
int color_index = heartrateC /10;
renderer.material.color = heart_colors [color_index];

Anyone want to do this for a few dollars?
Then contact me

it is done :slight_smile: