As of July last year "Textfield does not support styling at the moment. You can only apply styles with USS on the whole text field." (https://forum.unity.com/threads/code-editor-syntax-highlighting.706628/#post-4737053) - Just wondering if there was any rough eta that could be given for this and confirmation that this is in the works? Many thanks!
End of 2020? Thats a hella long time. Combined with the fact that you insert text as a property and not between tags like in HTML that's a huge oversight and even a showstopper for some, me included.
I second this. I thought "hey, lets move what I already nicely formatted for Console output into a new fancy Editor UIElements popup, Unity said it's production ready!". Turns out a) Popups in UIElements are hard b) no rich text support. Whew.
Yeah the "Production Ready" statements aren't to be trusted here (or anywhere Agile is used). I'd really prefer unity to keep these things in closed beta until they're at least on par (feature wise) with the tech/workflows they're trying to mimic as it leads to having to juggle a mix of assets/tools that may not work together. We've had to disallow the use of UIElements in our current project as including them causes our existing tool-set custom editors and inspectors to break when extending their functionality. (AFAIK, you can't show a UIE property drawer inside the inspector alongside an IMGUI property drawer) That being said, having spent a decade or so developing HTML + CSS web apps, i know i'd love UIE if they supported the standard CSS spec for styling elements.
Hi @PlayCreatively - good news! TextCore is a thing now. Check out https://forum.unity.com/threads/feedback-wanted-new-text-engine.1007585/. Having said that it's still very early days and I was unable to upgrade my project so I'm waiting before adopting it for now.
Nice, thanks for pointing that out! Just had to add com.unity.ui through the package manager and rich text is automatically working.
Has rich text support for UI Toolkit TextField-element yet surfaced in any Unity version? I tried going through some changelogs, but couldn't yet find references. I remember it was on the roadmap, I was wondering if there are any updates on it?
Rich text support was added in 1.0.0-preview.10: https://docs.unity3d.com/Packages/com.unity.ui@1.0/changelog/CHANGELOG.html We've been using it for quite some time and are happy with the implementation!
Ah yes, but at that time it wasn't implemented for TextField-element yet (for UI toolkit). So I was wondering if the TextField implementation is still in progress or out already.
Unfortunately TextField is a special case that will need to be reimplemented from scratch. At the moment of writing these lines, we're only a few weeks away from our internal 2021.2 feature freeze, so this refactor should take place in 2022.x
One suggestion for the reimplementation; Make text fields behave more similar to how labels behave. Currently making a tool where I create text fields in C# and something as simple as removing the background color (which should be blank by default) required multiple layers of trickery with the chance of errors on each layer. Having them start out at an empty container (possibly with placeholder/default text) which can then be styled and edited would simplify things a lot.
If I may add a couple of more suggestions. Current TextField has lot of locket behaviour that can't be changed by a property: * All text currently gets selected/highlighted when the field is focused. It would be really nice if one could toggle this off * Cursor style can't be currently changed. If one changes the background color of the TextField, it would be helpful to make the cursor color more contrasty and also have the ability to make it thicker. * We can't access current caret position within the TextField (for example if we would want to add a dropdown at caret position, autocomplete of some kind). It would be so nice to have all this changable via a property and accessable in the TextField class. Our use case is to make a text editor field for Editor-use. The way we would want to make our TextField is that once user clicks anywhere within the TextField (currently not in focus), with this one click the following would happen: 1) TextField gets focus without all text getting selected/highlighted 2) caret would be immediately transported to the click position 3) Once user would start typing, we would try to analyze latest word and render an autocomplete-dropdown using the caret coordinates. I know it's very special use case, but having this kind of stuff accessable (like caret position and focus behavior) from the class would be really helpful and it would be easier to extend the functionality when there aren't so many locked behaviour that can't be accessed from the outside.
The textFields (as all element ending in "field") are meant to be a field in an editor inspector : there is a label on the left side, and other small details that make it inline with the IMGUI component. As such, the styling, especially in the editor with the light or dark theme, need to be as it is. I think we need another component that will address more/different use case and potentially be used for the textFields. There is currently no way to select the text from a label for example, or to do an editable label using a double click and both would requires really different visuals compared to the textField I think you have listed interesting usages, and they will be shared with the team so that they are considered during the design.
Hi! Just wanted to inquire if there are some news or plans on this topic and especially the customizable text field element (or the new element to provide more customization)?
At the moment, our focus is still on the refactor of all InputFields to use TextCore, and we'll try to add as much customizability as possible (cursor color, caret position, highlighting...). No news about the new control, it's still on the drawing board.
Thanks for the update! This is great news! Also an incredible helper would be to be able to turn off auto-select-all-text-behavior upon field focus - currently all text is selected when a field is focused - desired alternative behavior would be to be able to just click anywhere on an unfocused field and the caret would be moved to that position directly without selecting any text. Currently we are using some focus hack that only works half of the time. Also some events for caret position change would be really nice! Is rich text support for TextField still on track for 2022 alphas/betas later this year?
This has been requested a few times, it will definitely be part of the refactor. Yes, it is, it's part of the ongoing refactor. Unfortunately, I doubt the refactor will be completed for 2022.1, but you can expect it to be completed for 2022.2.
Unfortunately it is not yet implemented in 2022.2 according to the documentation: https://docs.unity3d.com/2022.2/Documentation/Manual/UIE-rich-text-tags.html