GUI Text help needed!

I would like to display a box of text, the contents of which can be changed by a string variable. Using GUITextArea works fine - but I don’t want the user to be able to select text! Its a status readout and just needs to update when triggers are activated. I replaced GUITextArea with GUIlabel, but I can’t alter the contents of GUILable with a string… it just creates a new GUILabel on top of the old one. How do I create a simple, non user-editable text box?

I can do this by adding a GUITExt component in the inspector, but it would have been nice to keep the entire thing in one simple script!

I think what you want can be done with a Label. I do not understand what you mean when you mention drawing over the other one though, so maybe code would help.

e.g.

public string myString = "Hello, world.";

void OnGUI()
{
  GUILayout.Label( myString );
}

void MyTrigger()
{
  myString = "Goodbye, cruel world!";
}

After you call MyTrigger() the displayed text will change.

Molix has it right, GUI.Label can take a variable whose value you can change if/when needed and it’s not user editable/selectable text.

Thanks - I got this working with a GUIText element, assigned with a string variable visible in the Inspector, so its easy to see what Triggers send what message text.

GUILabel didn’t work for me when trying to change the content - I must have messed up somehow - changing the string variable on GUILabel resulted in the text appearing over the top of the previous string. I guess I was generating a new GUILabel everytime I changed the string somehow…