Search Unity

  1. Engage, network and learn at Unite Austin 2017, Oct 3 - 5. Get your ticket today!
    Dismiss Notice
  2. Introducing the Unity Essentials Packs! Find out more.
    Dismiss Notice
  3. Check out all the fixes for 5.6 on the patch releases page.
    Dismiss Notice
  4. Unity 2017.1 is now released.
    Dismiss Notice
  5. Unity 2017.2 beta is now available for download.
    Dismiss Notice

Text Box 2 beta

Discussion in 'Works In Progress' started by Jasper-Flick, Mar 5, 2014.

  1. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @rocki Awesome! How did you do it?
     
  2. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,291
    I added a SimplePanGesture and a Transformer2D comp to TextBox where the ClipedTextBoxCollider3D is on. The entire text can be scrolled and individual linked text can be clicked on. One thing I didn't quite get was getting the scrollbar to work correctly. When panning the text, the scrollbar does update, but when trying to move the scrollbar, it's not quite working.
     
  3. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @rocki If you pass along drag begin, update, and end events, the scrollbars should update the clip box. A small caveat is that single clicks or taps on the bar should also become a drag begin and end, just without any updates in between. Also, I'm using only a single collider for the track, while the scroller is only visual feedback and has no collider.
     
  4. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,291
    Thanks for the tips.
     
  5. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Just released beta 3.0.2, a small fix for UV2 and some related polish.

    Here is a mask example with UV2 mode set to TextBox and set to Character.
    mask-text-box.png mask-character.png

    New: Added custom inspectors for TextMeshRenderer, TextMeshCylinderRenderer, and TextMeshTorusRenderer.
    New: TextMeshRenderer now has a Character option for secondary UV mode. It fits the mask texture over each character individually.
    Fix: Secondary UV generated by TextMeshRenderer in TextBox mode are no longer vertically negative.
     
  6. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,291
    Love the Masking with the new UV. Wicked.
     
    Last edited: Sep 12, 2014
  7. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    I added a shrink-to-fit option because many people like to have it. It works by incrementally trying smaller text scales until it fits, so only use it when necessary.

    It starts with 10% scale adjustments and switches to 1% steps once it gets close to a fit, and then to 0.1% increments, and so on. You can control the order of magnitude of the precision. A precision of 2 should typically be fine.



    TextBox2 beta 3.1

    New: Added shrinkToFit option toTextBox.
    New: Added fitPrecision configuration toTextBox for shrinkToFit.
    New: Added EffectiveTextScale property to TextBox to get the effective scale when shrinkToFit is enabled.
     
  8. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    I'm working on getting in-game text editing and cursor support released. It's going well, but I won't finish it this week.
     
  9. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Currently digging through the 4.6 beta to see how text input would best mesh with it.
     
  10. jonc113

    jonc113

    Joined:
    Mar 10, 2013
    Posts:
    10
    I'm could really use the text editing function you mentioned. Any timetable on it's release?
     
  11. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Sorry! I had to make room for other priorities for a while. I hope to get back to this next month.
     
  12. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    And I'm back! Text Box 2 beta 3.2 has just been released!

    This update adds API to get cursor information from a text box, and of course a cursor means text editing. I've added a new "Text Editing" example that demonstrates some very basic text editing features. I decided to keep it very simple and release now, instead of trying to figure out the one true way to do text editing and take forever to deliver it.

    With the cursor API in place, you technically have all the tools needed to support text editing the way you want. It's just not out-of-the-box. I hope that after a few iterations we can come up with a canned solution that fits most people's needs.
     
  13. Burve

    Burve

    Joined:
    Feb 12, 2011
    Posts:
    137
    hmm, What I did wrong when after following tutorial in included PDF all seems right, however all my letters have black background ?
     
  14. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    That could be for multiple reasons, like how you setup the contour values or configured the texture. Compare your texture and material with one of the examples, see if you can spot the difference.
     
  15. Burve

    Burve

    Joined:
    Feb 12, 2011
    Posts:
    137
    hmm, Interesting, it seems my texture is a reason, however it is different question about fixing it.
    I used Bitmap Font Generator (First find on Google) to convert ttf to fnt (and what is interesting, your included demo don't have any fnt in it, it have no font from what I can find) and my application generated tga files for texture (hence such background problems), however saving them in Photoshop as png did not solve my issue.

    I would assume, that there is other application, that you used to convert ttf to fnt and it returns proper png ? What was that application ?

    On the same note - Application I used generated multiple tga files for me if I was interested in regular letters, special numbers, other languages, etc, however I did not notice (at first glance using your included tutorial pdf) ability to import bitmap font with multiple textures, there is an option for Styles, but that sound unpractical, or, returning to previous question, you magic application, that you used to convert ttf to fnt (assuming you used something and did not start with custom made texture) create all required symbols in one texture and I just got double unlucky with my first Google hit ?
     
  16. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Bitmap Font Generator (BMFont) should work. It's one of the option I list in the docs, and the font data format is specified by those guys. What you need is an output texture with alpha channel. I work with PNGs only, but Unity should be able to handle TGAs too. BMFont allows you to choose the output format. For the better font shaders you need to generate a distance map too. BMFont has an option to directly export signed distance fields, or you can generate one yourself.

    You get a texture and a FNT file, the latter has to be imported by a Text Box font asset. After that you don't need the FNTs anymore, which is why they're not included in the examples.

    Indeed the fonts can only work with a single character atlas each. You have to pack all the symbols that you need into one texture. Using the distance map approach you don't need very high resolution, so you can include many characters in a reasonably sized texture. Styles are mainly for switching visuals and mixing multiple fonts.
     
  17. Burve

    Burve

    Joined:
    Feb 12, 2011
    Posts:
    137
    hmm, interesting, I did not get BMFont to work (for some reason can't get transparency to work in it), however I found http://kvazars.com/littera/ that can generate what I need.

    Thanks for finding source of my error fast.
     
  18. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Weird that BMFont didn't do its job, but Littera is a fine alternative. Glad that it's working!
     
  19. MarkBTS

    MarkBTS

    Joined:
    Jan 8, 2015
    Posts:
    4
    @Jasper Flick Thanks for your work on this so far, it is looking great.

    I was just wondering now that 4.6 is officially released how the integration of Text Box 2 with the new Unity GUI was progressing. You previously said it was on your roadmap, was just wondering if you had any kind of ETA at this point,

    Cheers!
     
  20. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Hi @MarkBTS,

    I have no clear ETA at the moment. I managed to sprain both my ankles and that's slowing me down. I'm currently working on new shaders, which is a big update for this month. After that I'll do the 4.6 integration.
     
  21. MarkBTS

    MarkBTS

    Joined:
    Jan 8, 2015
    Posts:
    4
    Hi @Jasper Flick
    Ouch! Hope that you get those ankles fixed soon. Thanks for the quick reply, looking forward to seeing those shaders here too.
     
  22. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    I released a small update to help someone. Beta 3.2.1 adds a component to support scrolling the contents of a clip box by dragging the viewport directly. It can work either instead of or in combination with scrollbars. The clipping example scene demonstrates this.

    The big shader release is coming later.
     
  23. naladex

    naladex

    Joined:
    Jul 28, 2014
    Posts:
    6
    Hi! I would like to know if there is a caret placement option based on touch position for mobile, and also a scrolling function working fine on iOS and Android. Thank you!
     
  24. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Hi @naladex!

    Yes you can place a caret. The included 3D input functionality works fine with single finger usage on mobiles. I've included nothing for using mobile keyboards, though.

    Scrolling can be done by making the entire surface draggable, which is easiest for mobile input. That would conflict with cursor touches though. You can also use scrollbars, though you'd need to make their active area large enough to be usable. The 3D input also works fine on mobiles in this case.
     
  25. naladex

    naladex

    Joined:
    Jul 28, 2014
    Posts:
    6
    Thanks! I don't know if I understood correctly some of your answers (sorry for my poor english). Particularly the following:

    Do you mean that the plugin doesn't work with mobile native keyboard?

    Maybe I can explain a little better: I'm looking to mimic the functionality of this app, so I need that text input is done with the native keyboard both Android and iOS, being able to:
    -Do scrolling
    -Move The cursor to any index within the text.
    -Selecting Text.
    -Custom fonts.

    Furthermore, is it possible to try the plugin before purchase it? if not, is there a possibility of return if the plugin doesn't cover these needs? Thanks in advance!
     
  26. rahuxx

    rahuxx

    Joined:
    May 8, 2009
    Posts:
    501
    is it possible to have images/sprites to be loaded in between text at run time? Can we add sprites in text just like NGUI?
     
  27. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @rahuxx Yes, people have done so with custom renderers or by hacking a font asset. But it's not there out of the box. It's on the roadmap to make it easier.
     
  28. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @naladex Sorry, I missed your second message!

    I don't offer any native keyboard integration. So summoning the keyboard and consuming the typed content is something you or another plugin has to handle. Once you have the text, you can put it in a Text Box just fine.

    Scrolling, cursor placement, and multiple fonts are all possible. However, it's not a full-fledged text editor by any means. You can't beat native UI in that regard. As the fonts are put in atlases ahead of time, users also can't input characters you didn't include, which can get troublesome with Chinese typography and such.
     
  29. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    54
    Hey Jasper. I have a class that positions objects based on the bounds of a renderer. I want to use this to position icons next to text as in the image below. The issue I have is the bounds is based on the text width that's set by hand but the text gets generated programmatically. Is there a way to get the width to automatically match the size of the text object? Or get the true bounds of the text?

    https://www.dropbox.com/s/zsgjqr03azl827v/Screenshot 2015-03-03 12.59.38.png?dl=0

    Thanks for Text Box, been using it for a couple of years and it's been solid. (I'm on version 1.0.3 as I haven't felt a need to update)
     
  30. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @deekpyro For 1.0.3 it's probably easiest to insert mesh.RecalculateBounds() at the end of the box's update process. Then you can work with the exact mesh bounds. That adds some overhead, but for very small meshes like in your screenshot that shouldn't be an issue.

    Nice to hear you've been using it all these years!
     
    Last edited: Mar 4, 2015
  31. deekpyro

    deekpyro

    Joined:
    Oct 16, 2012
    Posts:
    54
    I'll give that a try, thanks Jasper.
     
  32. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    I just put beta 3.2.2 on the store. It's a tiny update that adds a tint to TextBox. It gives you a convenient way to adjust the text color or fade it out. It works by multiplying the tint with the style color, which becomes the vertex color for meshes.

    I've also been hard at work with shaders, specifically Unity 5's new surface shader code. I've generalized my approach and am now working on Standard SDF shaders, which I'll put in their own asset store product combined with my SDF generator tool. But I'll also bundle then with Text Box, so don't worry.

    This approach allows me to focus on the challenges of producing nice SDF shaders for Unity 5, regardless whether it's used for text or something else. I'm thinking about creating a separate topic for it and releasing a public alpha soon so people can get their hands on it and try it out on many different devices.

    So far I have a fully functional unlit shader that casts shadows and contributes to lightmapping and dynamic GI. I'm currently adding features to the specular version. The below screenshot shows a single SDF quad with semitransparent interior, proper reflections, and semitransparent shadows, but no lightmapping, normal maps, emission, or GI.

    sdf-specular-wip.jpg
     
  33. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    Beta 3.2.3 adds the JustifyComplete mode, which also stretches the last line of paragraphs.

    text-justice.jpg

    These tiny updates are prompted by people asking for specific features. If I can add them very quickly I'll do so and an update can be available very soon. So don't hesitate to ask, as you never know!

    The first draft of the specular shader is also finished. Both for forward and deferred rendering, though of course the latter only works when using alpha clipping. Now adding the metallic workflow.
     
  34. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,291
    Been on another part of the project for a while, just got back to Unity and really great to see TextBox2 coming along so nicely.
     
  35. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @rocki Thanks!

    I just made beta 3.2.4 available, to add a circle renderer that someone needed.

    circle-text.jpg

    I've also completed both the specular and metallic workflow standard shaders. Now I have to clean the code and create some demo material.
     
  36. rocki

    rocki

    Joined:
    Aug 10, 2012
    Posts:
    1,291
    Looks great.
     
  37. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    I started a new topic about my SDF work. Have a look!

    sdf-gi.jpg

    Future SDF talk goes into that topic. I'll only mention it here when it affects Text Box, which it will.
     
  38. BobBobson108

    BobBobson108

    Joined:
    Mar 13, 2008
    Posts:
    51
    This asset is great, but we are having an issue where the root object a TextBox is in is getting deleted when the game starts. This only happens sometimes.

    Also, is it possible to have cylindrical text be concave instead of convex?
     
  39. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    When you say root object, do you mean that the object with the TextBox component itself gets deleted? Or are you using a clip hierarchy and the entire object hierarchy disappears? I have no idea what could cause that.

    I'm not sure what kind of cylinder you want. You can use negative radius to invert the orientation.
     
  40. Marald

    Marald

    Joined:
    Jan 16, 2015
    Posts:
    6
    Hi Jasper,

    I just bought the text Box 2 asset to be able to have contours on text fields. Looked at text mesh pro as well, but this one doesn't give you contour options, which is just what I need.

    I had to make a tiny adjustment to the editor scripts, because on the scale I was working on, the contour gizmo's blocked the text field and swiching them off caused the script to collapse :(

    Examples all work fine in unity 5.3;

    I am no die hard c# coder, but can normally find my way around. But when trying to use the textbox component in my scripts, I am not allowed to put "using CatlikeCoding.Textbox" or any other catlikecoding for that matter, unless I copy my script over to the catlikecoding/examples folder. otherwise I have missing directive. Why is this and more importantly, how do I fix this?

    And another problem that occured after using Textbox 2 : MS VS does not autocomplete after I installed the textbox 2 in my project.

    I hope you read this forum regularly, as I need to finish this project soon.

    regards Marald
     
  41. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @Marald You're right, TextMesh Pro doesn't have contour support. There is something experimental on the TextMesh Pro forum, but nothing official yet.

    I am not sure what issue you're having with the namespace. Something like the following code should work.

    Code (CSharp):
    1. using UnityEngine;
    2. using CatlikeCoding.TextBox;
    3.  
    4. public class TextTest : MonoBehaviour {
    5.  
    6.     public TextBox text;
    7. }
    If that doesn't work, what specific compiler errors do you get?
     
  42. elliselkins

    elliselkins

    Joined:
    Mar 14, 2014
    Posts:
    5
    OK, getting started. I've created the bitmap font, bitmap font object in unity, style object, text renderer, and textbox. Everything is working except I'm only getting boxes for each letter. Seems like the alpha information for each letter is not being used?

    Capture.PNG
     
  43. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    778
    @elliselkins Make sure that you're using the alpha-8 texture format, and an SDF shader with appropriate settings. Compare what you have with the included examples.
     
  44. elliselkins

    elliselkins

    Joined:
    Mar 14, 2014
    Posts:
    5
    Ha, OK, found the solution after looking at the examples. Didn't put the font texture into the material. Thanks for the help!