Multiple text fields in OnGUI

Okay, it’s time to put my acorn of Unity knowledge to the test and I’m already a little stumped. I’m basically dealing with text labels, buttons and moving sprites (which have text labels on them) - see image below

My main concern is the text. So far I’ve worked out that the OnGUI script will handle most of the UI text nicely. But what if I wanted to have a text label (“something else”) that moves about with a sprite? It is also in a different style to the page title ("Title Text).

Having another GameObject attached to the sprite just doubles up the text, rather than separating them out.

Confused. This is clearly not the way to go, but if someone could point me in the right direction, or show me an example of something similar then please let me know.

Here’s my code so far

var windowRect : Rect = Rect (20, 20, 120, 50);
var customGuiStyle : GUIStyle;
var titleStr = "Title Text Here";
var charName = "SOMETHING ELSE";
var labelStyle : GUIStyle;
var titleStyle : GUIStyle;
var w : int = Screen.width;
var h : int = Screen.height;

function Start()
{
	titleStyle.fontSize = 32;
}

function OnGUI ()
{
	// title
	labelRect = GUILayoutUtility.GetRect(new GUIContent(titleStr), titleStyle);
	GUI.Label( new Rect (w/2-150, h/10, 360, 50), titleStr, titleStyle);
	
	GUI.Label(new Rect(100, 200, 300, 50), charName, titleStyle);
}

If I understand right what you want to do, I think it’s better and easier to put an 3D text above the sprite and child it. This way whatever the sprite moves the text will move too.

If you really need to do this using GUI then you should take a look at the Screen To World Position.

Hope it helps! =)