Using GUISkin, when I use GUI.skin = skin, the display is not as I require it.
Using GUI Skin in unity, Every time I try to use GUI.Skin, as GUI.skin in a programme, I set all the required sections in the GUI that I created. I receive nothing on the screen. public Rect timerRect; public float startTime; public string currentTime; public Color warningColor; public Color defaultColor;
public GUISkin skin;
void Update() { startTime -= Time.deltaTime;
currentTime = string.Format("{0:0.0}", startTime);
}
void OnGUI() { GUI.skin = skin; if (startTime < 5f) { skin.GetStyle("timer").normal.textColor = warningColor; } else { skin.GetStyle("timer").normal.textColor = defaultColor; } GUI.Label(timerRect, currentTime, skin.GetStyle("Timer"));
}
If I remove the reference to the GUI.skin = skin; Below displays the current time but not in the format I need. Can you help please Gordon? void OnGUI() { if (startTime < 5f) { skin.GetStyle("timer").normal.textColor = warningColor; } else { skin.GetStyle("timer").normal.textColor = defaultColor; } GUI.Label(timerRect, currentTime); }