Search Unity

Text Box

Discussion in 'Assets and Asset Store' started by Jasper-Flick, Feb 24, 2012.

  1. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @tayl0r: The problem most likely has to do with numerical precision hinting. It is probably solved by editing the relevant shaders, replacing all instances of the "fixed" precision with "half" or even "float". Let me know if this doesn't work.
     
  2. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    That fixed it. Thanks!
     
  3. poshaughnessey

    poshaughnessey

    Joined:
    Jul 12, 2012
    Posts:
    45
    @jasper Thanks. Adding some additional spacing seems to have helped.
     
  4. ChrisAtMyDream

    ChrisAtMyDream

    Joined:
    Jul 11, 2013
    Posts:
    1
    This is an awesome program we are currently using in our game. I had a few questions about it regarding the width and height of a string and word wrapping. I've noticed that if you have a line without spaces (such as aaaaaaaaaaaaaaaaaaaaaaaaaaaaaa), then the text wont wrap around the width of the bounding box. Is there a way to set it to wrap around despite the string being one long word.
     
  5. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @ChrisAtMyDream: Unfortunately Text Box only does word-wrapping, not word-breaking. There is no easy way to do this in general, so it's one of the things I consciously did not implement. You should really try to avoid such situations as it indicates your text space is too small for your content. The other options are rewriting to use smaller words or pre-breaking the words yourself. Hope you can make it work.
     
  6. totsboy

    totsboy

    Joined:
    Jul 12, 2013
    Posts:
    253
    Hello,
    I have followed the instructions on how to import and create a new CCFONT, but it still does not work, the text mesh is all black.
    Using windows and unity 4.2.
     
  7. totsboy

    totsboy

    Joined:
    Jul 12, 2013
    Posts:
    253
    It works when I apply diffuse material, but when I use any Text Box shader it doesn't. Do I have to do something specific when converting the font?


    Edit:
    Ok, solved it, was importing it wrong in BM FONT
     
    Last edited: Aug 29, 2013
  8. totsboy

    totsboy

    Joined:
    Jul 12, 2013
    Posts:
    253
    Is there any way to change alpha on runtime? I'd loike to use some fade effects on the text.
     
  9. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @totsboy: Yes. You can modify the alpha part of the CCText color, though you'll have to manually trigger the box to update itself, otherwise this'll be delayed until a text change. Alternatively, you can add a color or alpha slider to a copy of the shader.

    I'll be sure to include an ubershader in the future that makes all these tweaks a lot easier.
     
  10. Hamlet-Archer

    Hamlet-Archer

    Joined:
    Aug 21, 2012
    Posts:
    7
    hello. i bought a license for the word wrapping feature. it works great with english text, but word wrapping doesn't seem to work at all with CJK text (probably because there is no space between words). is there a way to make it work pls? thanks!
     
  11. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @Hamlet Archer: The wrapping needs spaces to work, it won't know where the word boundaries are without it. To make it work, you have to insert spaces between the words, or at least where you want wrapping to occur. You could also adjust the font's space width to a very small value, so spaces won't have any visual impact.
     
    Last edited: Dec 9, 2013
  12. Thormor

    Thormor

    Joined:
    Nov 22, 2012
    Posts:
    39
    Any updates coming up with the fixes for the warning that we now see with Unity 4.3?

    Happy new year btw!
     
  13. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @Thormor: Happy new year to you too!

    You mean the Undo-related warnings in CCFontInspector? They manage the undo state for importing a FNT file, which is not essential.

    Updating is a little tricky because many Text Box users still need Unity 3.5 support. I'm investigating the best approach here. If the warnings annoy you, it is fine to delete the four Undo method invocations. They are lines 48, 49, 54, 58 in CCFontInspector.cs. That'll solve this issue without having to wait for an update from me.
     
  14. bland_username

    bland_username

    Joined:
    Jan 9, 2014
    Posts:
    1
    Hi,

    I just wanted to say I purchased Text Box and it's awesome, the results are great. :D

    thanks
     
  15. petak_core

    petak_core

    Joined:
    Nov 19, 2012
    Posts:
    57
    Hi Jasper Flick ,

    first thanks for great asset Text Box, it's really awesome.

    but now I have some issue to solve...
    1) when I use Text Box (CCText Component) in my mainControll script, the OnGUI script does not working (don't show GUI Label, GUI Buttons), but if I have OnGUI function in another script OnGUI components is working (show to me some debug)
    2) when I use Text Box (CCText Component) and change some parameters for example Width it's doesnot change on Mobile device ( in the Unity Editor is everything OK) but on Mobile (Android) device is not. (my Text object are deactivate on Start)
    I think everythik was OK when it's everything settings come from Editor when I try change CCText compoment settings (parametrs) whith my script on Start there is no chage to see.

    Can you give me some tips or anything what Im doing wrog...

    (I test your demoScene on mobile and the scene was ok)
     
    Last edited: Jan 29, 2014
  16. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @_petak_ : If OnGUI isn't working, then the relevant component or game object has to be deactivated. Either from the start, or something switches it off later. It might even have been destroyed. Or it was never instantiated to begin with. Can you check the state at runtime?

    You are changing Width through scripts and it works in the editor but not on mobiles? What about desktop builds? Or do you mean inspector settings work but scripting doesn't, regardless of target platform? Are you adjusting the correct box instance?
     
  17. PopTwo

    PopTwo

    Joined:
    Nov 1, 2013
    Posts:
    7
    So... I love this product so far. Really having fun with it. Could you elaborate on the above a bit for me? I'm trying to use iTween to fade out some Outlined text. It's not working for me at all.
     
  18. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @PopTwo: iTween doesn't know about CCText, so to change its color you'll have to use a material with a _Color property. iTween will then be able to change this color. To make that work with outlined text, you'd need to make a copy of that shader, add a _Color property to it, and multiply it with both the text's normal and outline color. Then you can fade the text by going from fully opaque white to fully transparent white.

    Alternatively, write a script that updates the text box's color directly.
     
  19. PopTwo

    PopTwo

    Joined:
    Nov 1, 2013
    Posts:
    7
    Thanks for the quick reply! That seems a bit beyond what I'm capable of for the time being. I haven't done anything with shaders and I'm still learning c# in general. :(
     
  20. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @PopTwo: You can change a (renamed duplicate) of the outline shader like this:

    Add to the top of the properties block
    Code (csharp):
    1. _Color("Fade Color", Color) = (1,1,1,1)
    Below the sampler2D _MainTex line, add
    Code (csharp):
    1. fixed4 _Color;
    In the fixed4 frag function, change the return line to
    Code (csharp):
    1. return f.color * _Color;
    Then when using that shader on a box, you could fade it with iTween like this
    Code (csharp):
    1. iTween.ColorTo(myBox, new Color(1f, 1f, 1f, 0f), 5f);
    That adds a color multiplier to the shader's result, which can be changed by iTween. So changing the alpha component will fade the text.
     
  21. PopTwo

    PopTwo

    Joined:
    Nov 1, 2013
    Posts:
    7
    This worked like a charm. I didn't use the ColorTo for iTween. I did it like this (I'm using it for floating combat text:

    iTween.FadeFrom(damageText, iTween.Hash ( "alpha", 1, "delay", speed/2, "time", speed/2, "easetype", iTween.EaseType.linear));

    Great product. Great support!

    Thanks!
     
  22. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @Jasper,

    Reporting that I've been a happy customer of TextBox. It's an awesome package.

    TextBox is one of the earliest text packages on the asset store and it's still going strong.

    Would you consider a request to support dynamic fonts from the device in addition to the already excellent support for Bitmap Fonts.

    Updating TextBox to support this feature will make dealing with Asian languages much easier and of course would make TextBox that much more flexible and powerful than it already is.

    Cheers.
     
  23. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @rocki: Yes, I will definitely make it work with dynamic fonts. Unfortunately dynamic fonts have a very limited API, but I'll figure something out.
     
  24. chai

    chai

    Joined:
    Jun 3, 2009
    Posts:
    84
    I just bought Text Box, mostly for the wrapper features.

    But when I use cylinder wrapper I only see options for revolving around X,Y ... how do I make it revolve around Z ?

    Edit: ended up writing my own cylinder modifier, I'll be happy to send it over if you want

     
    Last edited: Feb 21, 2014
  25. chai

    chai

    Joined:
    Jun 3, 2009
    Posts:
    84
    Another thing, don't see anything in docs regarding character spacing, line spacing, etc ..
    Am I missing anything, or do we have to write it ourselves as well ?
     
  26. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    I hope you don't mind if I also mention my just-released solution for rendering Unity dynamic fonts in pixel-perfect way: Dynamic Text in Asset Store.

    This Dynamic Text component is an alternative for the built-in Text Mesh. It is meant for displaying pixel-perfect camera-facing text. The size and position are defined in world units. If compared to Unity's built-in text components, Dynamic Text is sharp like built-in GUIText, but part of the scene like TextMesh.

    It works by checking dynamically what pixel size the text should be rendered with current size and camera distance, and if a change is needed, requests glyphs with new size from the Unity Font and re-generates a mesh. It also snaps to nearest pixel to be pixel perfect.

    So, as this uses the same font importer and atlas renderer what Unity internally uses, it also uses the standard vanilla font material and shaders, so it's quite light-weight.

    The Dynamic Text website has more info (e.g. interactive demo for Unity web player or a YouTube video of the demo).

    However, the Dynamic Text component doesn't have support for extra special effects, and it is not ideal at all for a situation where the actual text size on screen changes all the time -- e.g. if one deliberately changes text size on each frame, or if the text is part of something which moves and rotates in 3D (e.g. by camera moving around in 3D).

    So, if the text is not camera-facing and mostly static, a SDF font rendering with a custom material is a superior solution. I'm explaining this stuff in Q&A section of the Dynamic Text web page, and linking to some already available alternatives which use SDF rendering, like this Text Box asset. :)
     
  27. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @Chai,

    Great work with the Z cylinder. Would love to have a copy. Can you post the code.

    Cheers.
     
  28. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @Tonic,

    Very cool text solution. Do you have some type of trial to test how it works on Mobile ?
     
  29. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @chai:Great that you made your own modifier! Do share in this topic.

    You can tweak the line spacing by adjusting lineHeight, which is a factor of the font's line height. There's currently no built-in way to adjust character spacing. Are you in need of this? A hack would be to adjust the font data or to adjust the caret advancement.

    @tonic rocki: Discussion about the Dynamic Text asset belongs in its own topic.
     
    Last edited: Feb 24, 2014
  30. chai

    chai

    Joined:
    Jun 3, 2009
    Posts:
    84
    No worries I've attached the modifier to this message cheers
    I also hacked char spacing in it.

    I think might be useful to have array of modifiers no ?
    E.g. mixing cylinder wrapping, gradients, character spacing, etc ...
    (I ended up merging those to one modifier, clumsy but works)
     

    Attached Files:

  31. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    116
    Is there a simple way to get the width of a single line of text?

    I've tried a few ways I could think of, but they all return the width of the textbox, not the actual text.

    Thanks keep up the great work, it's an excellent tool.
     
  32. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @chai: You could also made a combiner modifier, which holds an array of other modifiers that it applies in sequence. That way you won't need to combine them in code.

    @emsee: Currently there's no simple way. You'll have to run through the vertices, which is easiest with a modifier. You can detect line changes by looking at the first vertex of each sprite. Those with an x position of zero are at the start of a line. By looking at the x position of the vertex before that point, you'll get the used width of the previous line. This assumes you're using left alignment.

    I'm currently working on a big update that will make text inspection a whole lot easier.
     
  33. highlyinteractive

    highlyinteractive

    Joined:
    Sep 6, 2012
    Posts:
    116
    Sounds good - thanks Jasper
     
  34. RvBGames

    RvBGames

    Joined:
    Oct 22, 2013
    Posts:
    141
    TextBox looks impressive. Are there any editing features or just display?

    As it is I used GUIStyle with GUI.Label to create an edit control that provides horizontal scrolling and a cursor. Can the same be done with TextBox?

    Does TextBox eliminate the GC issues? I read the note about the GC and StringBuilder but want to make sure that I'm not substituting one GC problem for another.
     
  35. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @RvBGames: Using Text Box as an input field can work but requires quite some coding on your part. People have done it, but it's cumbersome. Luckily I'm working on version 2, which will make this as easy as it should be.

    Memory is only released when the box needs to increase its capacity (with a chunk size you can configure) and when you destroy it. Stay away from strings and you will have no GC woes.
     
  36. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    I have a very important announcement to make.

    $bloody-time-game.png

    Text Box version 2 is officially in development! You can check out the new features and its progress in a separate WIP topic.

    This will be a free update for everyone who already purchased Text Box. The release will also contain a package with the current version, so it'll remain available for those that still use Unity 3.
     
  37. NazimR

    NazimR

    Joined:
    Mar 12, 2014
    Posts:
    17
    Hey, Love your asset. It works very cool.
    Noticed that the outlines on the letters overlap the previous letters if they get too close. Is there any way to prevent outline overlapping?
     
  38. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @SomerSet: Thanks, great to hear!
    It really comes down to tweaking. You have to work with the room that the font leaves between characters. If it's tight, keep the outline thin, or move it further inside the characters. You will be able to adjust the letter spacing in the new version, enabling you to add room for the outline yourself.
     
  39. NazimR

    NazimR

    Joined:
    Mar 12, 2014
    Posts:
    17
    Ok, I see. It would be great if the outline was something like a seperate mesh behind the main letters so that you could create unlimited thickness in it without it overlapping the letters.
     
  40. NazimR

    NazimR

    Joined:
    Mar 12, 2014
    Posts:
    17
    Edit for above: I just realized I can do this by simply making a duplicate of the text box to put behind the first one with a thick outline. Silly me.
    Great Asset!
     
  41. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @SomerSet: Great you found a solution!
     
  42. NazimR

    NazimR

    Joined:
    Mar 12, 2014
    Posts:
    17
    I am using the new text box solution now, the 2.0 beta. I noticed that for the justification it automatically indents the first line. Sometimes quite a bit. In the old version the start of the first line would stay where you put it and the text would adjust white spaces instead for the justification. I liked that solution better, as I would like to be able to use text justification and control where the first line starts.
     
  43. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @SomerSet: What do you mean by indenting? The start of the line should remain unchanged. The only case it should move based on the rest of the text would be when the anchor wasn't set to top left.
     
  44. NazimR

    NazimR

    Joined:
    Mar 12, 2014
    Posts:
    17
    Woops, I found that I had made a mistake in my code that was adding a bunch of extra white space at the beginning of the first line.
     
  45. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @SomerSet: Great you found the culprit!
     
  46. EmeralLotus

    EmeralLotus

    Joined:
    Aug 10, 2012
    Posts:
    1,462
    @Jasper,

    I've been so busy with other parts of the app and didn't have a chance to properly try out Textbox2 until today. Super Happy with this new version even though it's just a subset of the work that you've been giving video previews of. It's definitely taking Texbox to another whole new level. Also code is very well written and crafted.

    Cheers.
     
  47. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    @rocki: I'm glad that you like it! I'll unlock more features in the next beta release.
     
  48. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    Beta 1.1 of Text Box 2 just became available on the asset store. It fixes a bug that only happened in builds, not the editor. You can now also retrieve the renderers used by a text box through scripting, instead of having to look for its children.

    Text Box 2 is now also included in the online code documentation.
     
  49. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    A new update is now on the store, beta 1.2. This fixes an alignment problem and adds the torus renderer that I mentioned above, plus the cylinder renderer.




    You create these wrapping renderers using the same prefab approach as the regular renderers. There are also special settings components that you can attach to text boxes, which allow you to control the shape settings per instance.
     
  50. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    959
    I have put a demo online that showcases the new clipping features of the upcoming beta 2.