Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

Text Box

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

  1. jdwieber

    jdwieber

    Joined:
    Mar 20, 2012
    Posts:
    28
    Hi Jasper,

    The tool and demo look awesome. Is there a demo showing how, or list of steps to take, to place a HUD in screen space? What about using TB with a GUISkin?

    EDIT: This is an image of the artifact I'm trying to overcome. I attached the textbox to the camera but it gets occluded by the wall of the room I'm in. The word North and the fps counter are generated by GUILayout and remain in screen space.



    EDIT: I'm not sure what's wrong with the image, but if you right click and open in a new tab it show up. I tried attaching it as a tiff and png, but get an error each time. My apologies.
    Thanks (again).
     
    Last edited: Jun 6, 2012
  2. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @jdwieber: You want the text box to ignore all depth information. There's two general approaches for this.

    1) You can do this by adding a second camera, set it to render after the main camera and have it clear the depth buffer only. Then place all text boxes on a layer only that camera renders. As this camera is independent of the main camera, you can keep it in a fixed location and place the text box in front of it.

    2) Alternatively, you can tweak the text box to use a shader that renders after everything else and has its ZTest set to Always.

    I suggest the first approach because it's more flexible and keeps the 3D world and 2D HUD completely separate.
     
    Last edited: Jun 6, 2012
  3. Charles-Van-Norman

    Charles-Van-Norman

    Joined:
    Aug 10, 2010
    Posts:
    86
    I didn't see anything specifically addressing pixel perfect rendering on iOS. I assume that anything I create with your middelware will look exactly like I want it to in the editor, then build to iOS at the same size in a pixel perfect manner. Is this correct?
     
  4. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @ccvannorman: Yes, if you set things up correctly.

    The usual approach to get pixel perfect stuff it to use an orthographic camera and set its size to half the screen's height. That will set the size of one Unity unit equal to one pixel. If you stick to whole numbers for placement and size, you'll exactly align your content with pixels.

    Text Box always uses a line height of one unit. So if your bitmap font has a line height of 40 pixels, you'll have to set its scale to a uniform 40 and you'll get pixel perfect text.

    This works the same for every platform, in the editor, web player, app, iOS, and so on. You do have to take into consideration that not everything has the same resolution. This is especially important for iOS devices, with the new iPad. If you don't do anything, your pixel perfect content will be half as large on the iPad 3 than on the other iPads. You either do that (not really an option), double your pixel size on the iPad 3 (effectively negating the retina display), add a double resolution version of the bitmap font (requires more space), or use a scalable approach (like with distance maps, which saves space but isn't pixel perfect anymore).
     
  5. Charles-Van-Norman

    Charles-Van-Norman

    Joined:
    Aug 10, 2010
    Posts:
    86
    @Jasper: Thanks. I have installed the product and it appears to scale nicely without much pixelation, even without following all those guidelines (those are great to have though--thanks)

    I was having trouble referencing CCText from javascript, because TextBox wasn't in the Plugins folder. If I moved it to the Plugins folder, the Inspector+Editor stuff broke.

    Solution: You must separate the TextBox folder after importing for everything to work smoothly. You have to move "Assets/Textbox/Editor" contents to the"/Assets/Editor/", and move the remaining contents of the TextBox/ folder to Assets/Plugins. That way, the editor inspector stuff works, and other scripts can reference

    Thanks!
     
    Last edited: Jun 25, 2012
  6. UnlimitedEdition

    UnlimitedEdition

    Joined:
    Feb 27, 2012
    Posts:
    287
    I love the picture that says something about always wanting to cast his shadow, it doesn't matter that it's just a shader effect.... can I use that photo as a profile pic.
     
  7. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @ccvannorman: I'm happy you already found a solution! Sorry for the complications, compilation order and editor folders confound things. For anyone interested, Text Box's C# code needs to be compiled before your own UnityScript code. See Script Compilation for more details.

    @DeadbodyPoka: :) Sure, you can use it!
     
  8. Pedro37

    Pedro37

    Joined:
    Jul 2, 2012
    Posts:
    3
    @Jasper Hi Jasper, I recently bought your plugin, everything is great !
    But since the last MAJ of unity (3.5.3), text in CCText doesn't render in my scene and i have got this error when i launch my project :

    MissingMethodException: Cannot find the requested method.
    UnityEngine.Mesh.Clear () (at C:/BuildAgent/work/14194e8ce88cdf47/Runtime/ExportGenerated/Editor/Graphics.cs:846)
    CCText.AddSprites (Int32 newSpriteCount) (at Assets/Text Box/CCText.cs:1105)
    CCText.AddSpritesFromString (Int32 i) (at Assets/Text Box/CCText.cs:1089)
    CCText.UpdateFromString () (at Assets/Text Box/CCText.cs:908)
    CCText.UpdateText () (at Assets/Text Box/CCText.cs:640)
    CCText.OnEnable () (at Assets/Text Box/CCText.cs:530)

    Could you confirm that bug is in your projects too ? and the way to solve it ? ;)

    Thanks !
     
  9. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Pedro37: I just updated to 3.5.3f3 and I get no such error. Do you have 3.5.3f3 as well? The exception you posted indicates that the compiler couldn't find the Clear method of Mesh, which should definitely exist. This method did receive an update though, it has gained an optional parameter.

    Could you could check whether Mesh.Clear exists in your version of the UnityEngine DLL? If it isn't there, you have a weird version of the Unity engine.
     
  10. Pedro37

    Pedro37

    Joined:
    Jul 2, 2012
    Posts:
    3
    Okay, i have just re-installed Unity and it's works perfectly.
    Thanks for your Assistance ! :)
     
  11. karl_

    karl_

    Joined:
    Mar 4, 2010
    Posts:
    464
    Hi Jasper. Really cool utility here. I have a question regarding importing fonts- namely, do I need to convert the font to a bitmap pre-import? Or can I simply load a TTF and allow Text Box to convert it for me? If the former, would you be able to recommend a TTF to BMP converter that is Mac compatible and at least semi-robust?
     
  12. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Pedro37: :) I'm glad that your problem is solved!

    @karl_: You'll have to convert the TTF to a bitmap font yourself. This requires more work on your part, but allows fine control, and you can also use the distance map approach to allow neat effects.

    I use a Mac myself and recommend the Themable Widget Library's font tool. It's part of a Java Webstart application, it's free, it's rock solid, and it's very usable.

    For more detailed information, I suggest you check the CCFont documentation or watch the demo video.
     
    Last edited: Jul 3, 2012
  13. Chris_Hagan

    Chris_Hagan

    Joined:
    Jul 4, 2012
    Posts:
    4
    Hi folks!

    I bought this toolkit a week ago and am extremely happy with its rendering and discoverability. Can anyone experienced in its use please advise as to how you'd go about making the created texts editable inline? Are there obvious points for extension? I appreciate that it's probably outside the intended scope, but thought someone might have some tips. Here are the main elements of my existing solution, along with their drawbacks:

    1) Where was the textbox clicked? Where should we place the cursor?

    "Find the clicked text, if there is one. Place the cursor within it at the clicked character."

    Code (csharp):
    1.             if(Input.GetMouseButtonDown(0)){
    2.                     var hit = new RaycastHit();
    3.                     if (Physics.Raycast(mainCam.ScreenPointToRay(mousePos),out hit)) {
    4.                         currentBox = texts.FirstOrDefault(t => t.ccText.HitCharacterIndex(hit) >= 0);
    5.                         if (currentBox != null) {
    6.                             var text = currentBox.ccText;
    7.                             var cIndex = text.HitCharacterIndex(hit);
    8.                             currentBox.cursorIndex = cIndex;
    9.                             text.Text = text.Text.Replace("|","").Insert(cIndex, "|");
    10.                             if(Input.GetKeyDown(KeyCode.Backspace)){
    11.                                 currentBox.Backspace();
    12.                             }
    13.                         }
    14.                     }
    2) What input has the user typed during this update cycle?

    (obviously, these code fragments are not intended to run outside of context):

    "Create an immediate GUI.TextArea outside of view, to capture the next (if any) characters typed. Inject those into our text, at cursor position".

    Code (csharp):
    1.  if (currentMode == ToolMode.TYPE)
    2.             {
    3.                 if (currentBox != null)
    4.                 {
    5.                     var dummy = "dummyBox";
    6.                     GUI.SetNextControlName(dummy);
    7.                     var input = GUI.TextArea(new Rect(-200, -200, 0, 0), "");
    8.                     GUI.FocusControl(dummy);
    9.                     currentBox.HandleInput(input);
    10.                 }
    11.             }
    12.  
    This solution enables me to have keyboard layout handled at framework level, as well as localization etc. The alternative, that of handling Input.GetKeyDown(key) for every member of Enum.GetValues(typeof(KeyPress)), leaves me vulnerable to a user who does not have their "@" attersand character, for instance, mapped to LeftShift || RightShift Alpha2. The downside is that Enter needs to handled separately in Update() rather than OnGui(), which is quite awkward at a maintenance level and might lead to race conditions between input handlers. KeyPress.Backspace does not appear to be handled at all.

    Anyway, that's today's work. It looks like a long road ahead to handle things like blinking cursors, selectable text, undo/redo etc. I'm still hoping there are API options I've missed somewhere that make this all more immediately achievable.

    Any advice anyone can offer would be extremely welcome during this design phase.

    Thanks!
     
  14. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Chris_Hagan: :) Cool to hear that you enjoy using my Text Box!

    Editable text is indeed not part of the scope of the product. It gets quite involved if you want full editable text box or text area functionality. But it's definitely something you could build on top of it. Here are some of my thoughts, filter them depending on how complex you want your input handling to be.

    You're making good use of HitCharacterIndex(), it's just too bad you end up calling it twice if there's a hit. But it's not a big deal.

    If you're going to change the text a lot, it makes sense to use a StringBuilder to prevent lots of string memory garbage.

    Using a "|" for a cursor kinda works, but it's a very primitive solution. I guess it's sufficient if you can't walk through the text, but otherwise it's really bad that the cursor position influences the text. Especially when it blinks! Ideally, use a different object for the cursor, which you render on top of of the text. This is more work but gives you the freedom to add lots of fancy stuff to your cursor without much of a hassle.

    If you can live with its restrictions, you can use Input.inputString instead of using a hidden TextArea in OnGUI. Then all logic can stay in Update.

    Hope it helps!
     
    Last edited: Jul 16, 2012
  15. Chris_Hagan

    Chris_Hagan

    Joined:
    Jul 4, 2012
    Posts:
    4
    Brilliant, thanks so much for your help! I'm looking into reading back the hit position of the selected triangles with an eye to placing a cursor object into worldspace.
     
  16. Chris_Hagan

    Chris_Hagan

    Joined:
    Jul 4, 2012
    Posts:
    4
    Hi Jasper,

    That was some good advice you gave me :D

    Input.inputString is exactly what I needed, that's fantastic.

    The cursor is now implemented as a TextModifier, so it no longer interferes with the text:

    Code (csharp):
    1. public class MeTLTextBoxModifier : CCTextModifier {
    2.     public MeTLTextBox context;
    3.     private VectorLine cursor;
    4.  
    5.     public override void Modify(CCText text)
    6.     {
    7.         if (cursor == null) {
    8.             cursor = new VectorLine("cursor", new[]{
    9.                  new Vector3(0f,5f,0f),
    10.                  new Vector3(0f,-18f,0f)
    11.             }, context.color, null, 1f, LineType.Continuous);
    12.             cursor.Draw3DAuto();
    13.         }
    14.         for (int i = 0, v = 0; i < text.Length; i++)
    15.         {
    16.             if (text[i] > ' ') {
    17.                 if(i == context.cursorIndex){
    18.                     cursor.vectorObject.transform.position = (text.vertices[v+1] * text.transform.localScale.x) + text.transform.position;
    19.                     break;
    20.                 }
    21.                 v += 4;
    22.             }
    23.         }
    24.     }
    25. }
    It doesn't ever place the cursor into whitespace though, for obvious reasons. Is there anywhere in the TextBox API that I can find out how wide whitespace is in the current font? Then we'd be very nearly done, which would be both surprising and awesome.

    A good API will get you a long way - totally worth the money :D

    c
     
  17. Chris_Hagan

    Chris_Hagan

    Joined:
    Jul 4, 2012
    Posts:
    4
    CCFont.spaceAdvance!
     
  18. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    :) Neat, I hadn't thought of using a text modifier that way.

    One thing that's a potential problem is that CCText doesn't keep track of individual spaces, it just skips over them. So it would require some extra logic to correctly positions the cursor inside a block of spaces. Tabs would be even harder.

    An additional thing you could do is position the cursor based on real character advance width, instead of sprite width. You can use the character data from the font to do the conversion. You could even take kerning into account. Of course, don't do that if the less involved approach is perfectly acceptable!
     
  19. ComfyBot

    ComfyBot

    Joined:
    Jul 23, 2012
    Posts:
    4
    Hi Jasper,

    I'm working on a project that requires text to be "typed out" onto the screen one letter at a time, as well as an audio sound to play with each letter (a quick beep or bloop) a very straightforward and typical kind of style you see in a lot of role-playing games.

    Is Text Box capable of doing something like that? I'm not much of a programmer but would absolutely purchase if getting something like that working isn't too big of a headache :p
     
  20. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @ComfyBot: Yes you can do that, though you'll have to provide the text-revealing functionality yourself.

    There are various ways to program it. The most straightforward would be to simply continuously assign a growing substring to the text box. Another approach would be to set the entire text at once but set the color to transparent, then update the mesh's colors of the characters incrementally. What method is best depends on the details of the effect and behavior you want.

    Here's a quick and dirty example that slowly adds more text to a box.

    Code (csharp):
    1. using UnityEngine;
    2. using System.Text;
    3.  
    4. public class TextRevealer : MonoBehaviour {
    5.    
    6.     public CCText textBox;
    7.     public float revealDuration = 0.1f; // how long it takes to reveal one character
    8.    
    9.     // handy property to check whether the revealer is ready
    10.     public bool IsReady {
    11.         get { return !enabled; }
    12.     }
    13.    
    14.     private string textToReveal;
    15.     private int currentIndex;
    16.     private float progress;
    17.     private StringBuilder revealedText;
    18.    
    19.     public void RevealText (string text) {
    20.         textToReveal = text;
    21.         currentIndex = 0;
    22.         progress = 0f;
    23.         revealedText.Length = 0;
    24.         textBox.UpdateText();
    25.         enabled = true;
    26.     }
    27.    
    28.     // Use this for initialization
    29.     void Start () {
    30.         revealedText = new StringBuilder();
    31.         textBox.StringBuilder = revealedText;
    32.         enabled = false;
    33.        
    34.         // test text for demonstration
    35.         RevealText("Hello!\nThis is a test reveal of some text for an awesome game!");
    36.     }
    37.    
    38.     void Update () {
    39.         progress += Time.deltaTime;
    40.         if(progress < revealDuration){
    41.             return;
    42.         }
    43.         progress -= revealDuration;
    44.        
    45.         revealedText.Append(textToReveal[currentIndex++]);
    46.         textBox.UpdateText();
    47.         // do some beeping here
    48.        
    49.         if(currentIndex == textToReveal.Length) {
    50.             // done, become inactive
    51.             enabled = false;
    52.         }
    53.     }
    54. }
     
  21. ComfyBot

    ComfyBot

    Joined:
    Jul 23, 2012
    Posts:
    4
    That's awesome!

    Thanks a lot Jasper. Text Box is pretty much exactly what I need then. Being able to justify, word wrap, the auto type and the ability to just throw it right on a mesh is exactly what I've been looking for. Will purchase soon (just waiting on payday :p)

    Again, thanks for the help.
     
  22. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    hi,

    i try with Arial font according to your demo video,but i cant write all fonts,some thing wrong.please help?

    dev
     
  23. UNITY3D_TEAM

    UNITY3D_TEAM

    Joined:
    Apr 23, 2012
    Posts:
    720
  24. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @devang_xprt: I'm not sure what you mean with "write all fonts". Can you provide more information?

    In case you mean that you cannot include some unicode blocks (character ranges), that would be because the Arial version you're using doesn't include them. Make sure you're using a Unicode variant.
     
  25. jalexz

    jalexz

    Joined:
    Sep 21, 2012
    Posts:
    1
    Hi Jasper,

    nice utility! I'm interested in using it but with Unity Pro 4.0.
    Do you plan to port Text Box for Unity4 once it is released?
     
  26. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @jalexz: Yes! It works just fine with Unity 4, but I'll definitely provide updates that take advantage of new features in Unity 4.
     
  27. Divide

    Divide

    Joined:
    Nov 10, 2010
    Posts:
    28
    Hey,

    Thanks for creating such an awesome product for a decent price! Lots of other libraries out there contain text rendering as part of a giant GUI framework and are rather pricey for someone who just wants a better text. This package is amazing and I love how that you bundled in a gradient editor! Its also very light weight code-wise, easy to use, easy to work with as an API (I love that you don't have to call UpdateText, it does it for you if you change a property). I would definitely recommend this to anyone who wants any text in their game.

    However, I'm in need of a few features and I was wondering if I could get any helpful advice for how best to implement these things.

    1. Inline pictures. I know that BMFont allows you to include icons and stuff in the text, but as I am using the shadow shader for the text (because distance map shaders are friggin brilliant and look so crisp! ) I dont think I'll be able to include the icons in the text without them being distorted. So I basically want to place the icons in an empty space where the icon would go as a separate game object. This means I need to be able to tell CCText to leave a gap of 32 pixels horizontally and it needs to work with word wrap - also i need to be able to obtain those co-ordinates.
    2. Markup. I saw you included a text modified that changes the colour of text between brackets, but it doesn't remove the brackets. I think I need to hook into the code that lays out the vertices and actually omit characters so they don't get used. Also I might need to include info after the bracket to control which color to use.
    3. This ones not important but I kinda wondered why you chose to make the text modifiers be assets instead of a component. Also if you had a list of modifiers rather than a single reference, you could potentially do more than one thing - for example use one modifier that warp the letters around a cylinder, and another one that colors every occurrence of 'just'.

    Again, thank you for creating this awesome product!
     
  28. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Divide: Nice to hear that you're enjoying it! :)

    1. Unfortunately there is no easy solution for this until I add multi-font support. You could include characters in your font that are empty but have the required with, either via font manipulation or hacking the CCFont asset with a script. Then those characters will leave the required gaps and you can scan the text so you know where to place your icons. Alternatively, you could adapt the shadow shader so its effect can be configured per character, which you could control via something like the alpha component of the color channel.

    2 3. The idea is to use a font without brackets (or any other characters you chose to use), in which case they won't cause you trouble. If you need multiple colors, probably the most convenient way would be to write your own modifier that can be configured with an array of (color, signal-character) pairs. That way you also leave the styling (specific colors) out of the content, using the signal-characters as sematics instead.

    The supplied modifiers are a starting point, demonstrating the things you can do by creating your own, either by reusing and combining the examples or by writing them from scratch. They're assets because they were initially seen as reusable styles, though they've grown beyond that. Initially I had no idea what people wanted to do with them, or if they would be used at all. Now that I've seen them used in the field, I can use that information to come up with something better for the future.
     
  29. Morgan_R

    Morgan_R

    Joined:
    Mar 4, 2011
    Posts:
    3
    This looks really nice. Any chance of an italics modifier in the future?
     
  30. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Morgan_R: I plan to add multi-font support, which will allow for italics and other effect.

    You could also make an oblique effect with a modifier that slants the characters, though whether that's visually acceptable is a case-by-case thing.
     
  31. digiross

    digiross

    Joined:
    Jun 29, 2012
    Posts:
    323
    Does this work on the Indie version?

    Also, does it support Unity 4?
     
  32. kellygravelyn

    kellygravelyn

    Joined:
    Jan 22, 2009
    Posts:
    143
    Finally picked up this asset today and it's working great. I had a few questions on how to solve a couple particular problems:

    1) When generating distance maps, what's a good size for the source texture? I have some text objects in my scene that don't look particularly smooth. I'm using the distance map generator and the Smooth shader. They look good if I get near them in the scene view, but in the game view I haven't been able to get them looking as nice.

    2) I have a text block that has two lines, each with four letters. What I'd like to do is A) space all the characters out such that they span the entire width of the text box and B) the letters on the bottom are bolded. I assume I can make such a modifier but I'm struggling on how to make it work, even while looking at the cylinder modifier. Got any tips?
     
  33. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @digiross: Yes, it works with the indie / free version. It doesn't depend on anything that requires a Pro license.

    Though not updated to take advantage of new features yet, it works fine with Unity 4.

    A general note: if some shaders give you trouble with Unity 4 on some platforms, try increasing the precision types of shader variables from "fixed" to "half". I've so far had one report that this was required.

    @nickgravelyn: Glad to have you on board! :)

    1) It really comes down to testing to figure out what you can get away with. Font, screen area, shaders settings, texture settings, angle, and effects can all influence how many pixels you need. Especially the texture import settings can be a foil if you don't set them right though: anisotropic level (for non-builboarded text), mipmaps (case-by-case), format (alpha only for distance maps), and compression (none).
    If the difference between the game and scene views is striking, investigate what different setting you're using for each.

    2) Considering the spacing, he quickest way would be to put a space between each characters to make them separate words, then use the justify alignment option and mess around until it looks like you want. Maybe tweak the space width of the font. You can't use a hard line break in that case though.
    The modifier approach would be to add up the width of the four sprites/characters on the line, then subtract that from the fixed box width. That's the total width of the empty space for that line. Divide that by three, and you have the offset between the spires you need to reposition them (this disregards kerning shenanigans).

    Considering the bolded part, you can use the example smooth bold shader plus modifier, if you can live with its restrictions. You can combine its code with your own modifier if you need multiple modifications. Alternatively, use a second text box. Less elegant, but then you could even use a true bold font variant at the cost of more texture memory.
     
    Last edited: Dec 12, 2012
  34. kellygravelyn

    kellygravelyn

    Joined:
    Jan 22, 2009
    Posts:
    143
    The format might be my issue for the distance map textures. I'm not sure I changed any texture formats. I'll take a look when I get back home to see if that helps. Otherwise I'll try some larger and smaller sizes to see what I can make look good.

    I tried using the Justify trick but it didn't take. Is there anything I might have been missing? The text box area was quite a bit larger but Justify didn't space out the four characters. Is there some maximum amount beyond which Justify won't work? I'm attempting to add quite a lot of whitespace between characters, equivalent to approximate 5-7 spaces worth.

    I'll give the modifier trick a go. When modifying vertices in the modifier, I noticed you loop over characters and each character reasonably has four vertices. To which corners do the vertices map? I didn't see anything readily apparent and wanted to avoid the trial and error situation. :)

    Thanks again. It's a great asset and so far is a pleasure to use after having tried the font solutions in another 2D package.
     
  35. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @nickgravelyn: The justification only works for word-wrapped lines and only takes the gaps into account, not how large they are. So I admit it's not really useful for precision-placement, unless you get a lucky hit.

    The vertex order of the sprites in the array is clockwise from the top left.

    v0 v1
    v3 v2
     
    Last edited: Dec 13, 2012
  36. shwa

    shwa

    Joined:
    Apr 9, 2012
    Posts:
    461
    How do i make the text visible from the front and back?

    thanks,

    shwa
     
  37. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @shwa: You have to edit the shader. Open the relevant shader and find this line near the top:
    Code (csharp):
    1. //      Cull Off // use this to make it visible from behind
    Remove the leading // from it to turn it on.
     
  38. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    Hi,

    I bought your text box. its nice tool and work with many language.But i have some problem. Shunk size not work.how i modify text size without using scale.

    because some cases objects are non uniform and i child text box it's also non uniform .when i scale text its become pixlet.


    play_edu
     
  39. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @Play_Edu: Sizing the text is done by universally scaling the Text Box's game object. If you're scaling the parent of the text but want to keep the text at the same size, then you'll have to inverse the scale of the text box to compensate. For example:

    Code (csharp):
    1. + parent scale: (2.0, 1.0, 1.0)
    2. ++ child text box scale: (0.5, 1.0, 1.0).
    Or, if you want easy control over the text size/scale as well, with an additional game object in between:

    Code (csharp):
    1. + parent scale: (2.0, 1.0, 1.0)
    2. ++ intermediate child scale: (0.5, 1.0, 1.0)
    3. +++ child text box scale: (1.0, 1.0, 1.0) or however you like to scale the text.
    Another alternative is to introduce a super-parent and rearrange the original parent and the text box so they become siblings:

    Code (csharp):
    1. + super-parent scale: (1.0, 1.0, 1.0)
    2. ++ original-parent scale: (2.0, 1.0, 1.0)
    3. ++ text box scale: (1.0, 1.0, 1.0) or however you like to scale the text.
    Which approach is best depends on your specific needs. Let me know if one of these isn't a viable solution.
     
  40. sauceypan

    sauceypan

    Joined:
    Nov 21, 2012
    Posts:
    6
    Hi there,

    I am trying to use animate the Text Box features using an animation clip to gradually change the alpha and the color of the text. Doing this manually through the Unity editor works fine as I can see the changes right away.

    However, as soon as I try to animate it, I don't see the changes visually in-game but I can see the values changing through the Unity editor.

    Essentially, if i try to animate any value on the CCText script (ie. color and alpha), it doesn't work. This is most likely a mistake on my end and any help or clarification would appreciated.

    Thanks
     
  41. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @sauceypan: CCText doesn't pick up changes set directly to its color value, bypassing its property, which is what the animation system does. One solution is to use a material with it own color - which ignores the CCText colour - and animate that. Another solution is to add code which calls the ResetColors method of the CCText component every (Late)Update. Either add it to CCText itself or to a companion script you create yourself. It's a good idea to cache the old color and only call ResetColors when it differs, otherwise the mesh colors get reset every frame.

    The absolute minimum code to see it working would be to add this to CCText:

    Code (csharp):
    1. private void LateUpdate () { ResetColors(); }
     
  42. Thormor

    Thormor

    Joined:
    Nov 22, 2012
    Posts:
    39
    Thanks man! Working as a charm
     
    Last edited: Feb 14, 2013
  43. jashan

    jashan

    Joined:
    Mar 9, 2007
    Posts:
    3,307
    This is pretty awesome - just what I need for ScoreFlash as a "simplest possible" UnityGUI replacement:

    At the moment, I'm in the process of adding Text Box support to ScoreFlash. I've already had NGUI support and EZ GUI support for a while, and eDriven.GUI support will soon come as well - but what I really like about Text Box is that it does just what is needed for rendering text based messages with ScoreFlash: Nothing less, and nothing more. This way, people that have Text Box will be able to use it with ScoreFlash for animating / scrolling messages (think of Scrolling Combat Text ... but ScoreFlash can do a lot more); and people already using ScoreFlash that want a simple 1-drawcall solution that supports nice effects could use Text Box.

    Here's an early prototype demo web player - I think this already looks pretty decent:
    Prototype Web Player: ScoreFlash using a custom renderer based on Text Box

    One thing I'm still struggling with are "dimensions": ScoreFlash does everything in screen based 2D coordinates ("pixel-perfect"), and it also needs to control the width of the messages. What exactly do you mean by "The width is in local space units." (docs for CCText / Word Wrap)? I would assume that when I'm using the ortho-cam based approach (one world unit = one screen pixel), I should be able to set "Width" using pixels but ATM, I never get word wrapping because the values I'm setting (pixel values) are way too large.

    Also, once I'm able to correctly set the width, how can I figure out the height for a given text in screen coordinates? At the moment, I have implemented my GetSize as follows - but I'm pretty sure this is not correct:

    Code (csharp):
    1.     public override Vector2 GetSize(ScoreMessage msg) {
    2.         TextBox.Text = msg.Text;
    3.         return new Vector2(
    4.             TextBox.Width,
    5.             TextBox.LineCount * TextBox.Font.pixelLineHeight);
    6.     }
    7.  
    I can also post the "integration package" later on - but at the moment, ScoreFlash 3.1 is still pending review (this only includes the "glue" to make the two work together - neither Text Box nor Score Flash are included ... for obvious reasons ... so as that package requires ScoreFlash 3.1 and no one can download that, yet, it doesn't make sense to already provide a link to that package).
     
  44. Play_Edu

    Play_Edu

    Joined:
    Jun 10, 2012
    Posts:
    722
    hi,

    nice work but can it work like NGUI dynamic font system

    because it's easy to use
     
  45. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @jashan: Sorry, I totally missed your post. Nice to hear you're adding support for Text Box to ScoreFlash!
    "The width is in local space units." just means that it is subject to the object transform's scale. So if the width is 2 but you scaled the whole thing up by 10, the world-width is 20.
    The used height is equal to LineCount * LineHeight (default 1 unity unit). So if you've set LineHeight to the pixelLineHeight or scaled by it, then your calculation is correct.

    @Play_Edu: I'm not familiar with the NGUI dynamic font system, so I guess it doesn't work like that. Text Box used a fixed font atlas that has to be created in advance, in any case.
     
  46. poshaughnessey

    poshaughnessey

    Joined:
    Jul 12, 2012
    Posts:
    45
    @jasper I'm not getting output from BMFont that seems to work, and I'm assuming it has to do with having incorrect "Font settings" and "Export options" from BMFont. Would you mind posting screenshots of the typical BMFont settings that you use? Thanks!
     
  47. poshaughnessey

    poshaughnessey

    Joined:
    Jul 12, 2012
    Posts:
    45
    I was able to get pretty good results by switching to GlyphDesigner. However, I am seeing some artifacts where the edges of the individual letters will sometimes be rendered when using the "Text Box/Alpha Blend" shader.
    $FontEdgesShowing.png

    Have you encountered this before and know if there is a way to correct it?
     
  48. Daniel-Talis

    Daniel-Talis

    Joined:
    Dec 10, 2011
    Posts:
    425
    Spacing between lines seems very wide.
     
  49. Jasper-Flick

    Jasper-Flick

    Joined:
    Jan 17, 2011
    Posts:
    957
    @poshaughnessey: There's something bleeding into the character quads. You typically solve this by adding some padding to the character bitmaps. Use at least 1px padding on all sides. Let me know if this doesn't solve your problem.

    @Daniel Talis: How much space there is between lines depends on the line height of the used font. You can adjust this via the LineHeight property, which is a factor that gets multiplied with the font's line height.
     
  50. tayl0r

    tayl0r

    Joined:
    Jan 6, 2012
    Posts:
    85
    We just released an Android game with this plugin and I'm getting reports back from users with Galaxy Nexus and LG Optimus L9 devices that say their text is very faded and hard to read.

    Here is an example from our game: http://i.imgur.com/rPxgWyv.png

    And here is the CC Test app running on a Galaxy Nexus (broken): https://dl.dropboxusercontent.com/u/59304/cctext-broken-galaxyNexus.jpg
    And here is the CC Test app running on a Nexus 7 (working): https://dl.dropboxusercontent.com/u/59304/cctext-working-nexus7.png

    Has anyone seen this issue before?

    It works fine on iOS devices and on the Nexus 7 and Samsung Galaxy S3. As far as I know only the Galaxy Nexus and LG Optimus L9 devices are affected. But, they both use the PowerVR SGX540 gpu so it might be a problem with that gpu, since none of the devices we know work use that gpu. I'm not 100% sure though.

    Any info? Any tips on how I could potentially fix it? The shaders I'm using are the built in ones. Smooth, Smooth Outline, Smooth Shadow.

    Thanks!
    Taylor Steil
    Fox Cub Games