GUI.Label disappeared in Unity4

I have recently upgraded my Unity from 3.5.0 to 4.1.2, after upgraded my project, I run it and found that all GUI fonts disappeared. They are coded in this way:

void OnGUI() {
    Rect rect;
    int num;
    GUIStyle style;
    GUI.Label(rect, num, style);
}

How to fix this? Thanks.

maybe you need to re-assign the font in the inspector?

–

I tried but no luck. I noticed that font will appear if I use "None" for Font, but see nothing when I use custom font. My font can be used in Unity 3.5

–

when using a custom font maybe you also need to set the font size a little higher, like to 16-18? Also, make sure your rectangle appears on screen, if you have negative values in your rect there's a big chance its simply to small or off screen.

–

Actually, your code doesn't make any sence to me at all :S I think how one would usually tpye it is like this: Rect myRect = new Rect(0,0,200,200); GUIStyle myStyle; //now you can assign all the GUIStyle properties in the inspector. void OnGUI() { GUI.Label(myRect,"hi",myStyle); }

–

Just to tell you what function I used for diplaying the GUI, it's an existing project running in Unity 3.5

–

1 Answer

1

I solved the problem, end up it’s because the name of font is in Chinese character, fonts appear after i changed the ttf name to English. Not sure why Unity 3.5 can read it but not Unity 4.1