Search Unity

How to edit rich text in textArea?

Discussion in 'Immediate Mode GUI (IMGUI)' started by BIV1991, Jan 29, 2015.

  1. BIV1991

    BIV1991

    Joined:
    Jan 26, 2015
    Posts:
    7
    I just need edit colored text!
    I even try use 2 pass gui rendering, with simple editable text in textArea and colored label above it, but bugs in unity was (annoing space behavior).
     
  2. BIV1991

    BIV1991

    Joined:
    Jan 26, 2015
    Posts:
    7
    SOLVED
     
  3. ducanhtuvu

    ducanhtuvu

    Joined:
    Jul 22, 2012
    Posts:
    20
    Can you share
     
  4. RedGirafeGames

    RedGirafeGames

    Joined:
    Sep 30, 2016
    Posts:
    32
    Agree... a share would be well received :D
     
  5. kalagaan

    kalagaan

    Joined:
    May 27, 2012
    Posts:
    1,503
    Here a simple version for color only.

    Code (CSharp):
    1.  
    2. GUIStyle style = new GUIStyle();
    3. style.wordWrap = true;
    4.  
    5. txt = GUILayout.TextArea(txt, style);//edition
    6. Rect r = GUILayoutUtility.GetLastRect();//get the text area position
    7.  
    8. style.richText = true;
    9. EditorGUI.TextArea(r, AddHighlight(txt), style);//highlighted
    10.  
     
    Last edited: Mar 19, 2020