How to move GuiText to front?

static var scorepoints: int = 0;
var windowRect : Rect = Rect (20, 20, 120, 50);

function AddToScore() {
   scorepoints++;
}
      
function OnGUI () {
   windowRect = GUI.Window (1, windowRect, BringWindowToBack, "SCORE BOARD");
}

function BringWindowToBack (windowRect : int) {
   guiText.text = "Points : " +scorepoints.ToString();
}

The GuiText seems to appear behind the gui window…how to bring it to front ?

Ernest

Um, you cant mix the GUI types…

guiText is the old gui system that is not part of the OnGUI stuff. guiText is a gameobject that you move forward/back in depth using its transform.z position, like any other gameobject.

Stuff inside OnGUI will always be drawn over the viewport.

You want to change the guiText.text stuff to be…

function BringWindowToBack (windowRect : int) { 
   GUI.Label(Rect(0,0,100,50), "Points : " +scorepoints.ToString());
}

but im using a custom font + texture for the GuiText…how can i implement it into OnGUI functions?

You can make GUISkins… read up on your documentation, or search the forums here for info about how to do it,

The new GUI system is VERY flexible, once you learn how to use it all.

GUISkins are limited to using mono-colored TTF fonts, though. If you need to control how stuff is layered, like Seon said, you can’t mix OnGUI with GUIText…use one or the other.

–Eric

hmm alright :slight_smile: Thanks !