Search Unity

Code Editor / Syntax Highlighting

Discussion in 'UIElements' started by joshcamas, Jul 7, 2019.

  1. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    756
    Hello!

    I'm wanting to create a code editor in unity using UIElements. However, I do not want to start from scratch. (Build a text editor with all of the features such as select and such). In other words, I'd like to modify the built in text field.

    Any ideas on how I should begin? I'm new to UIElements, I understand the basics but I'm not intuitive at it

    Thank you
     
  2. patrickf

    patrickf

    Unity Technologies

    Joined:
    Oct 24, 2016
    Posts:
    43
    Textfield does not support text styling at the moment. You can only apply styles with USS on the whole text field.
     
    joshcamas likes this.
  3. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    756
    Alright, makes sense :)

    I've managed to get a nice editor up and running by using uGUI by having a transparent text area as the input, and a text area on top of that with rich text / syntax applied as the visual. It works pretty well ^_^
     
  4. DGordon

    DGordon

    Joined:
    Dec 8, 2013
    Posts:
    397
    I had to do the same thing a couple of years ago in IMGUI, and wound up layering a label over a textbox, or something like that. Please think about adding support for this. We make heavy use of custom editors, for Dialogs, Quests, Scene logic, to a load of other things. We don't want a custom scripting language since we want the compiler to catch every error it can (makes my life debugging everyone elses scripting much easier), so I have editors that allow you to write your custom scripts in c#, and then the editors create c# files from their data when saved.

    I really just want to have a single textfield / textbox that I can style however I want as needed ... it would clean things up tremendously in the future.
     
    joshcamas likes this.
  5. joshcamas

    joshcamas

    Joined:
    Jun 16, 2017
    Posts:
    756