Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Gui.TextArea problem

Discussion in 'Immediate Mode GUI (IMGUI)' started by LagLemon, Feb 20, 2010.

  1. LagLemon

    LagLemon

    Joined:
    Feb 20, 2010
    Posts:
    12
    I've been trying to use GUI.TextArea, and have found that it cuts off the text at a certain point. Even though I have more written in it, it completely ignores it, and I've got no idea why. Below is the code I've been using - Any help would be much appreciated.
    Code (csharp):
    1. function Update () {
    2. }
    3.  
    4. var scrollViewVector : Vector2 = Vector2.zero;
    5. var speechTrigger1 : String = "Brim Masino:  Things are looking pretty calm here. Reminds me of the first few days\n after they  commissioned MIKA.\n Damn. Back then this was a busy city. You used to be able to head down to the park and watch the leaves fall…\n but enough reminiscing – now is not the time to be dreaming of leaves, now is it?\n I hope we run in to some of those damned Cloud Cobra dogs! Wait! We’ve got some activity up ahead!  Radar  three targets.\n  Go ahead and engage!\n I’ll be rooting for you!" ;
    6.  
    7. var showSpeakerWindow: boolean = false;
    8. var showPlayerStats: boolean = false;
    9.  
    10.  
    11.  
    12. function OnGUI () {
    13.  
    14.     // Begin the ScrollView
    15.     scrollViewVector = GUI.BeginScrollView (Rect (400, Screen.height - 100, 405, 100), scrollViewVector, Rect (0, 0, 400, 250));
    16.  
    17.     // Put something inside the ScrollView
    18.     innerText = GUI.TextArea (Rect (0, 0, 400, 400), speechTrigger1, 1000);
    19.  
    20.     // End the ScrollView
    21.     GUI.EndScrollView();
    22.    
    23.     if (showSpeakerWindow)
    24.         GUI.Box (Rect (300, Screen.height -100, 101, 100), " Blah" );
    25.     if (showPlayerStats)
    26.         GUI.Box (Rect(0, Screen.height -100, 300, 100), "Blah blah");
    27.  
    28.    
    29. }
     
  2. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Hi, welcome to the forum!

    Can you give a bit more detail about what is happening? When you say the text cuts off, is the text box itself too small or does the text stop before the end of the box? Does it stop at any significant point (like a line break) or after a certain number of characters, or ... ?
     
  3. LagLemon

    LagLemon

    Joined:
    Feb 20, 2010
    Posts:
    12
    Hi,

    With my variable speechTrigger1 I have a large amount of text within it. When I try to call that variable to display within the text area, only half of the text within that string appears in the box.

    (for example, it will print only this much of var speechTrigger1 : String = "Brim Masino: Things are looking pretty calm here. Reminds me of the first few days\n after they commissioned MIKA.\n Damn. Back then this was a busy city. You used to be able to head down to the park and watch the leaves fall…\n but enough reminiscing – now is not the time to be dreaming of leaves, now is it? and then it ends.

    The line break I tried to put in also seems to get ignored, and doesn't actually work.

    It also removes all of my punctuation, and no matter what I do to edit the variable, it never shows the changes.


    [/quote]
     
  4. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Sorry for not noticing this before - you need to assign the result of GUI.TextField to the same variable you pass in:-
    Code (csharp):
    1. speechTrigger1 = GUI.TextArea (Rect (0, 0, 400, 400), speechTrigger1, 1000);
     
  5. LagLemon

    LagLemon

    Joined:
    Feb 20, 2010
    Posts:
    12
    Thanks :)
     
  6. LagLemon

    LagLemon

    Joined:
    Feb 20, 2010
    Posts:
    12
    still having a bit of a problem with it. It doesn't update the text when I make changes to the string variables. I can make changes to the string, and it saves properly, but it keeps the same text it had originally, as if I hadn't made any changes at all.
     
  7. andeeeee

    andeeeee

    Joined:
    Jul 19, 2005
    Posts:
    8,768
    Can you post the code in its current state?
     
  8. LagLemon

    LagLemon

    Joined:
    Feb 20, 2010
    Posts:
    12
    The script ended up being the same one I posted at the top. I didn't make any changes to it.
     
  9. ippdev

    ippdev

    Joined:
    Feb 7, 2010
    Posts:
    3,850
    Is it possible that you did not change the string in the Inspector? My buttons will take the script values the first time but after that I have to use the Inspector to alter strings I added to the script..unless I remove the GUI Object and redrop the script on another empty game object...Then I get my strings as they are scripted but lose any GUIStyles I set in the Inspector.

    HTH
    Randy
     
  10. LagLemon

    LagLemon

    Joined:
    Feb 20, 2010
    Posts:
    12
    I tried changing it in the inspector, but no luck so far. Thanks for the information :)