I've searched couldn't find a clear answer. Maybe I missed it. I have a text area that i want to load text into from a text file that I've added as an asset. Is there a way in C# to load the text directly to the GUI.Box along with line breaks so it wont just be one long line of text in the Gui.Box?
I just did a quick test and the line breaks came in no problem in a default GUI.Box from a TextAsset. e.g.
public TextAsset textAsset;
void OnGUI()
{
GUI.Box( new Rect( 0, 0, Screen.width, Screen.height ), textAsset.text );
}
Maybe if you're not seeing the line breaks there could be an issue with the text asset itself (line breaks often have platform specific quirks).
You can also use the WWW class to load resources from the hard disk, by using Application.dataPath
var www : WWW;
var text_: string;
function LoadAndDisplay()
{
www = new WWW(Application.dataPath + "/file.txt");
yield www;
text_ = www.text;
}
function OnGUI()
{
if (text_)
GUI.Label(new Rect(0,0,100,30), text_);
}