Search Unity

Text format inside GUI elements

Discussion in 'Immediate Mode GUI (IMGUI)' started by scarpelius, Mar 27, 2011.

  1. scarpelius

    scarpelius

    Joined:
    Aug 19, 2007
    Posts:
    966
    I want to make a chat window, much like wow chat. For that i need to be able to:
    • individually format (color) pieces of text inside the gui element who display the text.
    • create links, clickable areas maybe

    I've started the code with a GUILayout.Label but it doesn't seems to be the element I need. I guess i need something like an html gui element to achieve this but i do not know wich one (if there is one).
    Any idea is appreciated.
     
  2. reissgrant

    reissgrant

    Joined:
    Aug 20, 2009
    Posts:
    726
    This help?

    Code (csharp):
    1.  
    2.  
    3. function OnGUI() {
    4.  
    5.     GUI.contentColor = Color.yellow;
    6.     GUILayout.Label("this text is yellow");
    7.  
    8.     GUI.contentColor = Color.red;
    9.     GUILayout.Label("this text is red");
    10.    
    11.     GUI.contentColor = Color.white;
    12.     GUI.backgroundColor = Color.blue;
    13.    
    14.     if( GUILayout.Button("this is a blue button with white text")   ){
    15.    
    16.    
    17.         print("the button has been clicked");
    18.    
    19.    
    20.     }
    21.    
    22.     GUI.backgroundColor = Color.white;
    23.    
    24. }
    25.