Unity Community


Results 1 to 10 of 10

  1. Posts
    12

    Gui.TextArea problem

    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:  
    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.    
    22.     if (showSpeakerWindow)
    23.         GUI.Box (Rect (300, Screen.height -100, 101, 100), " Blah" );
    24.     if (showPlayerStats)
    25.         GUI.Box (Rect(0, Screen.height -100, 300, 100), "Blah blah");
    26.  
    27.    
    28. }

  2. Unity tech writer

    Location
    Blackpool, United Kingdom
    Posts
    8,696
    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 ... ?
    I'm wired to the world... that's how I... know... everything...


  3. 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. Unity tech writer

    Location
    Blackpool, United Kingdom
    Posts
    8,696
    Sorry for not noticing this before - you need to assign the result of GUI.TextField to the same variable you pass in:-
    Code:  
    1. speechTrigger1 = GUI.TextArea (Rect (0, 0, 400, 400), speechTrigger1, 1000);
    I'm wired to the world... that's how I... know... everything...



  5. 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.

  6. Unity tech writer

    Location
    Blackpool, United Kingdom
    Posts
    8,696
    Can you post the code in its current state?
    I'm wired to the world... that's how I... know... everything...


  7. Posts
    12
    The script ended up being the same one I posted at the top. I didn't make any changes to it.


  8. Location
    Atlanta, GA
    Posts
    722
    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


  9. Posts
    12
    I tried changing it in the inspector, but no luck so far. Thanks for the information

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •