x


Text appears really faint

I have a script that writes some text OnGUI(). My other OnGUI() scripts seem to work fine, but this one seems to look horrible even though it's the same writing technique.

alt text

A) What I see against a black background B) What I see against a grey background C) It should be White (255,255,255,255).

All of my other screen elements are bright white and they show up as such.

Any help would be appreciated.

Jason

more ▼

asked Mar 03 '12 at 11:08 AM

Lethil gravatar image

Lethil
65 3 7 8

Try a new font maybe? Look into GUI skins... file:///Applications/Unity/Unity.app/Contents/Documentation/Documentation/ScriptReference/GUISkin.html

Mar 03 '12 at 07:24 PM KrisCadle

I've tried the handful of fonts and they all end up this way. Moreover, this is the only OnGUI() call that seems to cause this. The other 4 calls on this screen work correctly (showing white text).

Mar 03 '12 at 07:29 PM Lethil

Is there any way you'd be able to share the OnGUI code where this is being called, or other aspects of the project that might help get to the root of the problem?

The color may be caused if you have set the font material color to be black; in which case even if the GUISkin is set to white, the white -or unaltered -version of black is still going to be black.

Mar 03 '12 at 08:42 PM Alec Slayden

Absolutely:

void OnGUI ()
{
    float height = 20F;
    for(int i = 0; i < _MissionInfo.MissionTasks.Count; i++)
    {
       GUIStyle style;
       if(((MissionInfo.MissionTask)_MissionInfo.MissionTasks[i]).Completed)
         style = MissionCompletedStyle;
       else
         style = MissionNotCompletedStyle;
       GUI.Label(new Rect(Screen.width-150, height, 150, 25), ((MissionInfo.MissionTask)_MissionInfo.MissionTasks[i]).FriendlyText, style);
       height = height + 25;
    }
}
Mar 03 '12 at 09:18 PM Lethil
(comments are locked)
10|3000 characters needed characters left

2 answers: sort newest

If it's caused by someone else fading your color, and you can't fix that, a hack is to use super-white -- an RGB of 512. You can't do that in the color-picker, but you can do it in code (well, usually.)

The code uses 0-1 for the channels (Color.white is 1,1,1,1,) so GUI.color=new Color(2,2,2,1); is double-white. It just looks white, but suppose someone blends it with black. It gets cut in half to "only" (1,1,1), which is still fully white instead of the grey it would have been.

more ▼

answered Mar 03 '12 at 08:36 PM

Owen Reynolds gravatar image

Owen Reynolds
11.3k 1 7 45

That definitely fixes it. I noticed I can either "super-white" it or I can "super opaque" it as well (1,1,1,2) to fix it. The one catch is that it gives the color an inconsistently bright light.

I'm glad to know why, but I'll look for something a bit more consistent in result. Thanks for the help!

Mar 03 '12 at 09:17 PM Lethil
(comments are locked)
10|3000 characters needed characters left

Wow, um... so... yeah... it turns out the reason that I was having issues was that 2 gameobjects had the OnGUI() draw script. I removed one of the dupes and it works like a charm now.

more ▼

answered Mar 04 '12 at 02:03 AM

Lethil gravatar image

Lethil
65 3 7 8

After having no end of trouble with turning on/off multiple menus in multiple scripts, I've resolved to only ever use one big OnGUI, with functions/flags everyone has to talk to.

Mar 04 '12 at 04:10 AM Owen Reynolds
(comments are locked)
10|3000 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Topics:

x313

asked: Mar 03 '12 at 11:08 AM

Seen: 415 times

Last Updated: Mar 04 '12 at 04:10 AM