- Home /
GUI Material Problem
Hi All!
I got a little problem when adding a material to a GuiText. The material has a standard GUI/Text Shader on it, and is set to red. Unfortunately, when added, it makes Blocks out of the font, wich is the standard one btw..
What am I doing wrong? Anybody any idea??
With Material:
Without Material
And this is the script used to generate the Timer
private var startTime;
var restSeconds : int;
var roundedRestSeconds : int;
private var displaySeconds : int;
private var displayMinutes : int;
var countDownSeconds : int;
function Awake() {
startTime = Time.time;
}
function OnGUI () {
var guiTime = Time.time - startTime;
restSeconds = countDownSeconds - (guiTime);
if (restSeconds == 60) {
print ("One Minute Left");
}
if (restSeconds == 0) {
print ("Time is Over");
}
roundedRestSeconds = Mathf.CeilToInt(restSeconds);
displaySeconds = roundedRestSeconds % 60;
displayMinutes = roundedRestSeconds / 60;
text = String.Format ("{0:00}:{1:00}", displayMinutes, displaySeconds);
guiText.text = text;
}
I don´t know why, but the line with roundedRestSeconds = $$anonymous$$athf.CeilToInt(restSeconds);
isn´t being displayed in Code format..
Because your indentation is all over the place. That line looks tabbed.
Answer by Waz · Sep 08, 2011 at 02:31 AM
You probably want this answer, although really it's simpler to just use OnGUI and set GUI.color.
Thanks! But every solution is I found there is not really usefull to me. I am using a OnGUI function by the way, and GUI.color doesn't work though. I've posted the script I use above!
Strange, it has worked for many other people (see the up vote counts).
By "use OnGUI", I mean actually draw the text there, with GUI.Label().
Your answer
![](https://koobas.hobune.stream/wayback/20220612204430im_/https://answers.unity.com/themes/thub/images/avi.jpg)