Hey guys, I started code 2 weeks ago and now i reached a point were i need a textarea. But I have no idea how to do that. The textarea should display something like: Player hit with 5 dmg. Monster hit with 2 dmg. and ever 1 second (i got the timer) it add a line please help me
C# Code: (This script is named textDisplay) Code (CSharp): public static string textToDisplay = ""; void OnGUI(){ GUI.Label(new Rect(0,0,Screen.width,Screen.height),textToDisplay); } Then if you would like to change the text from another C# script Code (CSharp): textDisplay.textToDisplay += "My New Text \n"; The \n is a new line. The same can be done in Javascript but someone would have to convert my code for you.
ok thanks for ur reply. I think i can convert for my self. I will try it and post the java script if it work. the box: Code (JavaScript): function Start () { PlayerPrefs.SetString("textToDisplay", ""); } function OnGUI () { GUI.Label(new Rect(Screen.width*0.4f,Screen.height*0.7f ,Screen.width/3,Screen.height/5),PlayerPrefs.GetString("textToDisplay")); } the text: Code (JavaScript): function Update () { textToDisplay = PlayerPrefs.GetString("textToDisplay"); textToDisplay += "Hello World! \n"; PlayerPrefs.SetString("textToDisplay", textToDisplay); } But my someone can tell me how i can limit the height of the box so it dont went all over the screen.
... nope: Code (JavaScript): function OnGUI () { scrollPosition = GUILayout.BeginScrollView ( scrollPosition, GUILayout.Width (Screen.width/2f), GUILayout.Height (Screen.height/4f)); GUILayout.Label(PlayerPrefs.GetString("textToDisplay")); GUILayout.EndScrollView (); }