Search Unity

  1. Welcome to the Unity Forums! Please take the time to read our Code of Conduct to familiarize yourself with the forum rules and how to post constructively.
  2. Dismiss Notice

The problem with the transfer of the text in GUI.Box

Discussion in 'Scripting' started by Alexonus, Feb 4, 2013.

  1. Alexonus

    Alexonus

    Joined:
    Feb 2, 2013
    Posts:
    11
    Code (csharp):
    1.  
    2. if(DisplayButtons1 == true) {
    3. GUI.Box(Rect(Screen.width / 2 - 150, Screen.height / 2 - 100, 300, 200),"bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla bla");
    4. if(GUI.Button(new Rect(Screen.width / 2 - 50, Screen.height / 2 + 100, 100, 40),"OK"))
    5. {
    6. DisplayButtons1 = false;
    7.  
    8.  
    9. }
    10.  
    11. }
    12.  
    13.  
    how to put text in a column?
     
  2. Alex Cruba

    Alex Cruba

    Joined:
    Aug 16, 2011
    Posts:
    564
    You will need a style for it... First of all your head should look like this:

    Code (csharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class YOURSCRIPTNAME : MonoBehaviour {
    5.    
    6.     public GUISkin MYSKIN;
    Then go Project Inspector and create GUI skin.

    Define a style (YOURSTYLE) now and check "Word Wrap". You may have to play around with "fixed width".

    After that your box codeline must look something like this:

    Code (csharp):
    1. GUI.Box(Rect(Screen.width / 2 - 150, Screen.height / 2 - 100, 300, 200), "bla bla bla", "YOURSTYLE");
    2.  
    1st advice: I just use the box text for headlines. GUI Box is just my empty window. After that codeline I do a normal GUI.Label.

    2nd advice: Maybe you work with more text and maybe in different languages. Think about a seperate script only for your text. This way you just have one variable and the overview is much better.

    3rd advice: As I wrote I just use the Box plain and add content over Box.Label. Maybe you have always the same Box size but the length of text must be variable. Working with a Label inside the Box you

    a) just need one style for text
    b) need just one style for Box
     
    Last edited: Feb 4, 2013
  3. Alexonus

    Alexonus

    Joined:
    Feb 2, 2013
    Posts:
    11
    thanks friend! ^ _ ^
     
  4. Alex Cruba

    Alex Cruba

    Joined:
    Aug 16, 2011
    Posts:
    564
    Welcome. Still having problems/question - tell me.