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

Pixel-Perfect Dynamic Text - Support Thread

Discussion in 'Assets and Asset Store' started by tonic, Feb 16, 2014.

  1. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Hey Tonic, thanks for the thorough reply.

    Ok well I worked around all that stuff. I still would prefer an override for SetText since I want to intercept that and update some fx. Instead I need to do things backwards and use my fx component that sits next to DynamicText to update the text and then update the fx. Ideally I'd just extend DynamicText to do the fx itself.

    On another topic, I have DynamicText in a scene that doesn't have a camera. This is because the game composes several scenes together at runtime. In this situation, DynamicText spams the console because it can't find a camera. Once the game runs though, it picks up the main camera. This is fine because I'm not relying on the camera distance for DynamicText right now.

    Even if I do care about the camera that it uses at some point, it'd be nice to be able to shut off that camera error. A bool in the inspector to either not use a camera, or suppress the error, would be great.

    Thanks for considering this feedback!
     
  2. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @benthroop, thanks again for feedback. I'll try to see what'd be a good way to take these kind of use cases.
     
  3. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Sure. I have a feeling there are other use cases based on the fact that DynamicText is currently the only asset that lets users use dynamic fonts AND get a hold on the mesh data. Unity TextMesh obscures the mesh data. All other plugins don't use dynamic fonts. So I would imagine there are other users out there that grabbed it for reasons that we did, like bending the text and doing other fx at runtime.
     
  4. Exeneva

    Exeneva

    Joined:
    Dec 7, 2013
    Posts:
    432
    Does this work with Unity 4.6?
     
  5. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Exeneva, yes - Dynamic Text does work with Unity 4.6.

    However, note that compatibility with UI solutions is limited or up to some manual tweaks to make the two work better together. For example, instructions pdf (and the Dynamic Text website) has this comment about trying to use Dynamic Text asset with the new uGUI:

    Does Dynamic Text work with the new uGUI introduced in Unity 4.6?
    No, with some exceptions. It is possible to have Dynamic Text in a scene which uses uGUI. But if you want Dynamic Text object to be part of the GUI, then it will reasonably work only if you use World Space render mode in the Canvas. Additionally you may have to use only a single camera (no separate UI camera with dynamic rotation or so). In addition you have to add a script to tweak sorting order of Dynamic Text objects - for example in C# something like this:
    GetComponent<DynamicText>().renderer.sortingOrder = 1;
    This will allow you to use Dynamic Text as a label or in buttons with uGUI. However, you still can't use it to represent text with uGUI Input Fields.
     
  6. peterfrog

    peterfrog

    Joined:
    Dec 13, 2013
    Posts:
    9
    Hi Tonic,

    I had a problem on android.

    1. create a new scene
    2. create a dynamic text gameobject
    3. Player Settings - Default Orientation , set auto.
    4. Build & Run.
    5. switching Portrait then landscape. again. again.
    6. hang

    Tested OK - Nexus5, Galaxy S3
    Tested Fail - LG Optimus G Pro, Galaxy Player

    I'm using Unity3d 4.5.4f1 basic

    Need Help. any suggestions?

    Thanks
     
  7. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @peterfrog. I'll try to investigate this. But can you answer a bit more details about your steps 2 & 5:

    Was the dynamic text object you created just the simple default one which says "Text", or did you use your own longer text - and did you perhaps use different set of "metrics ref chars"? What about the Font, did you use the default (built-in Arial), or did you change to a font of your own? What about the given text size, min/max px size, are those the defaults? And finally, the text location - assuming you have the default perspective camera, was the text close to it so that it took a large part of the screen?

    And, what about the step 5 -- is that specifically 3 switches, or just doing it many many times?
     
    Last edited: Sep 20, 2014
  8. peterfrog

    peterfrog

    Joined:
    Dec 13, 2013
    Posts:
    9
    2. just default. don't change anything.
    5. sometimes 1, 2 times. sometimes 5 times. vary.

    camera is Ortho. New Project -> create a 2D project.

    Tested IOS - iPad2 , iPod 3rd gen. It's OK.
     
  9. peterfrog

    peterfrog

    Joined:
    Dec 13, 2013
    Posts:
    9
    One more thing.

    Default GUIText and 3D Text was OK. but Dynamic Text was not.
     
  10. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    What about build settings - do you have the Development build and script debugging flags enabled? Or are you perhaps using Unity 4.5 Pro Android with multithreaded renderer?

    When trying to replicate the bug, I noticed that for some reason the Unity Android player now freezes for me if I build with Unity 4.5 and use Development build and script debugging flags. But when I try to build with same flags using 4.3, I don't get the same issue at all. Would it be possible for you to test with Unity 4.3 as well? (It might be that this issue I'm seeing is something totally different though...)

    My first thought was that it could be a memory issue - the Galaxy Player seems to be an old device with very limited memory, and flipping the orientation back and forth will usually retrigger rebuild of the font atlas. When that happens, it is possible to have a freeze if the used font sizes are too big for Unity to fit in the atlas even after some retries, which should be possible to fix with lowering max font px size... But that should not happen with the simple test case you described. And it also looks like the LG device you mentioned should not have similar memory issues.

    Note that the default GUI Text or 3D text do not need to update the atlas after scene has been loaded, as they don't need to fix the font size, so they can keep using the same mesh.
     
  11. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @peterfrog, unfortunately I don't have the same devices you do, and I seem to be unable to replicate this issue. I'm still interested in the more exact details of the setup: If the camera is orthographic, is it using the default Size 5, so that the dynamic text has size 1 and thus its height is 10% of the screen height?

    Out of curiosity (still trying to categorize the issue), could you do a small test:
    Set the dynamic text object's "Max Font Px Size" to 10 (a very small number). This will force the text to look ugly in this case, but don't worry about that. Just build and test if you still get the same issue with that test case.

    Additionally, can I assume you're seeing the same problem when you build and run using the included "DynamicTextExamples" scene?
     
  12. peterfrog

    peterfrog

    Joined:
    Dec 13, 2013
    Posts:
    9
    @tonic , you are right.

    ----
    do you have the Development build and script debugging flags enabled? - No
    are you perhaps using Unity 4.5 Pro Android with multithreaded renderer? - No. basic and not multithreaded.
    ---

    1. "Max Font Px Size" to 10. it's ok. no hang.
    I don't have LG G Pro, too. so no test that device. (two days ago, I reported issue who playing my game.)

    2. "DynamicTextExamples" same problem.

    I wonder. If a memory problem, why first loaded scene was good. after changing orientation was bad?
     
  13. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @peterfrog, I'll try to explain why the orientation change often requires bunch of more memory with Dynamic Text:

    Normal text mesh or gui text only use same font size always - so when you change orientation, it uses the same texture what was already built. However, they have their own disadvantages - text mesh can be blurry or jaggy if the requested pixel size isn't just the perfect match for current camera setup, resolution and dpi... or gui text size can be very different when comparing to world size units (depending on resolution and dpi).

    So, Dynamic Text is built to address those problems. But orientation change means effectively also resolution change (the camera has different vertical screen resolution), so one world unit will be different amount of pixels. Because of this, to maintain the roughly same text size in world units, Dynamic Text needs to have a font texture in different pixel resolution, and re-create the mesh using that. On the orientation change, it will figure out what pixel size is required, and request that Unity's own Font system adds the required text characters to the font atlas texture. If all the characters do not fit in the new texture, then Unity basically deletes the current texture, tries to create a new one (possibly bigger than previous), and adds the requested characters. However, this results in callback to all text objects which will then recreate their text meshes, or will also request their needed characters to texture, which may even lead to again flushing and re-creating the font texture, trying to have enough space for all. So, this means the memory requirement can jump up a bit at that point, and if the device was one which was already very low on memory, it's going to be a problem naturally. Alternatively if the text is configured to be relatively big, and there are lot of characters needed (or defined in the Dynamic Text font metrics string even if they aren't all needed), that can apparently end up in an endless loop when Unity tries to fit in all characters in new size(s) but it keeps failing. So, to prevent this, for now the only sure way to prevent is to design for small enough max font sizes.

    Whew, that was a wall of text! Sorry for not being able to explain it shorter. :) Hopefully it still makes some sense.

    However, I'd still like to find some way to fix this thing. I think I will try to add a feature which does a best effort to detect if the app is flushing&recreating the texture again and again, and when that happens, automatically reduce the max pixel size to "save" the situation. Which in lower end devices means the visual quality of text can suffer, but it would surely be better than hanging.
     
  14. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @peterfrog - I'm still working on this. However, I'm pretty sure that the issue is a memory issue like I suspected, and looks like it will be possible to add the fallback feature of reducing quality to prevent a hang. At least I'm now able to reproduce an issue like that even on desktop / in editor, and also detect the situation in code. Hopefully it will also work out on mobile devices.
     
  15. peterfrog

    peterfrog

    Joined:
    Dec 13, 2013
    Posts:
    9
    @tonic - good news. I really appreciate it!
     
  16. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi all, especially @peterfrog and @benthroop. I just released v1.0.5 with following changes:
    - Fix: In some cases SetText didn't work properly when called from Start().
    - Added automatic fallback to smaller font pixel sizes in case of font atlas rebuild loop (due to low memory or using too large text).
    - Can suppress debug logging by setting dt.suppressDebugLogs=true from script code.

    I know there are some other wishes too, but I've been busy and only had time to rush these fixes/changes in.
     
  17. benthroop

    benthroop

    Joined:
    Jan 5, 2007
    Posts:
    262
    Thanks @tonic.

    Hey just a bug report - I am animating the Color.a value of the text in an animation (Mecanim style, not legacy) and though I can see the value changing in the inspector, the text object is not updating. It works when I drag the animation timeline but not when it is actually playing in the game. If you can think of a workaround let me know.
     
  18. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @benthroop - Any chance you could put up a small test case project and send a link to me privately? I ask because that sounds like I might not do an identical setup when trying to replicate the issue.
     
  19. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @benthroop - I just tried that myself and indeed I can't replicate the issue - animating the Color alpha works fine for me, both while in inspector in editor and in the play mode. (Using the Animator with a state and setting up changes for the state in Animation view.)

    Could you please verify that the Dynamic Text component is actually enabled? The component won't actively react to changes like animated color alpha if it is disabled, but in editor the custom inspector will still make it do changes e.g. to the text mesh if you change the text, so it may slip unnoticed if the component is accidentally disabled. Your case sounds like this might be happening.
     
  20. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    12
    We continue to use the plugin and are very happy with its performance.

    However, we just discovered a leak that we're hoping you can fix. It looks like DynamicText is leaking its mesh when destroyed. It doesn't happen in the editor, but it does on iPhone. I haven't tested any other platforms. It is significant for us because we have a very text-heavy game and its memory footprint can double in just a few minutes.

    Below is some sample code that should allow you to reproduce the leak. Add this script to an object in a scene, create a prefab with DynamicText, and reference the prefab in this script.

    Code (CSharp):
    1. using UnityEngine;
    2. using System.Collections;
    3.  
    4. public class DynamicTest : MonoBehaviour
    5. {
    6.  
    7.     public GameObject prefab;
    8.     DynamicText dt;
    9.  
    10.     public void Start () {
    11.         StartCoroutine(RecreateText());
    12.     }
    13.    
    14.     private IEnumerator RecreateText() {
    15.         while (true) {
    16.             yield return new WaitForSeconds(1f);
    17.             if (dt != null) {
    18.                 // Uncomment this line to fix the leak
    19.                 // Destroy(dt.GetComponent<MeshFilter>().sharedMesh);
    20.                 Destroy(dt.gameObject);
    21.             }
    22.             GameObject go = (GameObject)Instantiate(prefab, Vector3.zero, Quaternion.identity);
    23.             dt = go.GetComponent<DynamicText>();
    24.             dt.SetText(Time.time.ToString());
    25.         }
    26.     }
    27. }
    28.  
    If you profile this on an iPhone, you will see the mesh count increase every time the object is destroyed and recreated in the memory profiler. You will also see the Meshes go up in Simple mode and and, in Detailed mode, you will see Not Saved > Mesh increasing with every sample.

    If you uncomment the commented line, the leak disappears.
     
  21. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Flyclops, nice to hear you like it, and thanks for detailed bug report.

    How urgent is it for you to get a new build? I'm asking because I have a very busy month ahead...
     
  22. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    12
    I'll DM you with some thoughts.
     
  23. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @Flyclops, I managed to find a bit of time and thanks to your excellent bug report & way to workaround, I believe I fixed the bug and it took just a small moment. I sent you privately a test build. Please report back when you have the chance and tell me if it works for you now.
     
  24. Flyclops

    Flyclops

    Joined:
    Apr 19, 2013
    Posts:
    12
    Leak is fixed! Thanks, @tonic, for the quick response.
     
  25. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    That's great news. Thanks @Flyclops for testing it!
     
  26. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    I'm making a 2D game that will have some trucks with dynamic text signs controlled by C# script. Can this be done with Pixel-Perfect Dynamic Text?

    Also, how to get the 43% discount?

    Thanks.
     
  27. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @username132323232, that sounds like this package would work for you.

    However, you should be aware of these things beforehand:
    • If you use a specific package for doing 2D stuff, or even the new uGUI part of 4.6, there's no guarantee for compatibility. Please check out the "Questions and Answers" part in first on this web page: http://strobotnik.com/unity/dynamictext/
    • By default the visual look of the text is simple in the same way that the unity built-in text mesh is. This asset even uses the same shader and texture than the built-in text, so it's light-weight but no special effects - unless you do some extra work yourself, like make a custom shader.
    To update text frequently from a script, be sure to use the variant of updating the .textSB field (a string builder), and when you're done, then call .FinishedTextSB(). This way there won't be unnecessary leaks of temporary strings.

    The currently available discount is already applied in the selling price, as long as the sale is on (the baseline price has been $35 for quite a while, and it's $20 currently during the sale).
     
  28. OnePxl

    OnePxl

    Joined:
    Aug 6, 2012
    Posts:
    307
    Oh S***, I bought it assuming it was compatible with uGUI, or at least would be. But you're saying it will never be?
     
  29. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @OnePxl, well on the part of uGUI one could say there is compatibility to some extent, but it isn't really very smooth in the way that it isn't easy to make the text part of all that UI (the text is not part of the GUI Canvas system). But, when using the world space render mode, I think Dynamic Text does a better job with text. One has to do a bit of extra tweaking though.

    Here is an excerpt from my site which talks about this (with some emphasis):

    -- Does Dynamic Text work with the new uGUI introduced in Unity 4.6?
    No, with some exceptions. It is possible to have Dynamic Text in a scene which uses uGUI. But if you want Dynamic Text object to be part of the GUI, then it will reasonably work only if you use World Space render mode in the Canvas. Additionally you may have to use only a single camera (no separate UI camera with dynamic rotation or so). In addition you have to add a script to tweak sorting order of Dynamic Text objects - for example in C# something like this:
    GetComponent<DynamicText>().renderer.sortingOrder = 1;
    This will allow you to use Dynamic Text as a label or in buttons with uGUI. However, you still can't use it to represent text with uGUI Input Fields.
     
  30. Deleted User

    Deleted User

    Guest

    Why doesn't the text face the camera? Even in the demo scenes, if I move and rotate the cameras, the text never makes any attempt to face the camera. For example, I can't edit the script because it's in a dll so please explain. You're description says "camera-facing text".
     
  31. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @AaronBrownLM -- The description says that way since this component is meant to be used with such situations - i.e. for example with a camera which is always facing in the same direction, and not a free-flying 3D camera.

    However, you're perfectly right that there still should be additional support which enables it to automatically face towards camera. I think I'll add this as checkbox to a future version.

    For now here is a quick additional component you can add to get this effect, save this code to DTFaceCamera.cs:
    Code (CSharp):
    1. // DTFaceCamera.cs
    2.  
    3. using UnityEngine;
    4.  
    5. [ExecuteInEditMode]
    6. [RequireComponent(typeof(DynamicText))]
    7. public class DTFaceCamera : MonoBehaviour
    8. {
    9.     Camera cam;
    10.  
    11.     void Update()
    12.     {
    13.         if (cam == null)
    14.             cam = GetComponent<DynamicText>().cam;
    15.  
    16.         transform.LookAt(transform.position +
    17.                          cam.transform.rotation * Vector3.forward,
    18.                          cam.transform.rotation * Vector3.up);
    19.     }
    20. }
    21.  
     
  32. _josh

    _josh

    Joined:
    Dec 18, 2014
    Posts:
    7
    hey, just wanted to say your plugin is great! It definitely helped in alot of ways.
    But I am running into an issue where I'm consistently getting this:
    "Font px size reduced to x.xxx due to rebuild callback loop (likely low on memory or using too large text)."
    I have no idea where this is coming from and it is kind of hard to debug this b/c your code is currently closed. This is what I can tell you:
    - it happens in the editor occasionally, but happens more frequently on mobile devices
    - I'm using the dynamic text in a game that uses alot of text. I have text in every view, some more than others.
    - I don't get the warning right away, but happens over time. So I'm assuming something is growing the atlas to a size too big? I have no clue. I'm on a phone that has a lot of memory, and I still get it, which means something is growing within the app?

    Sorry, I know this isn't alot of info :/
     
  33. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @_josh, nice to hear you like it.

    The error you're hitting is a fallback I've added to detect an "impossible" situation and try to gracefully get out of that. To explain what's going on, I'll first describe how Unity's Font system fills the font atlas texture for a particular font. Dynamic Text uses internally the same font system what's used by Unity's own Text Mesh ("3D Text") for example.

    So, the characters (glyphs) used by some text needs to be rendered to a font atlas (a special texture) before it can be used in a mesh to show it in scene. Whenever the font size is changed, all glyphs need to be rendered again to the atlas using the new size. Unity will helpfully manage the atlas in a way that it uses the still available free space for the new glyphs. If there isn't enough space, it will re-allocate a new bigger texture, copy the current one as part of it, and then start filling the new empty space.

    It may be helpful to peek how that looks - try to click on the Mesh Renderer's Materials->Element 0 (Font Material). If you're using the built-in Arial, double-click to view the material, or if you're using own ttf, you may need to manually select/expand the font and select Font Texture under it. If you pick some Dynamic Text in editor, and just for fun of it wiggle the Size field up and down, you'll notice the texture will dramatically change.

    So, the question is, what happens when Unity runs out of space in the font atlas, and if it has already hit the maximum size what the font atlas texture can be grown into? At that point it will start all over again from an empty one - forgetting all the previous sizes & glyphs it has rendered. Whenever it re-allocates the texture, it'll inform with a callback that this is now happening, so that any script interested in it can tell again what glyphs does it really needs to be added again to the font atlas, and then re-create the mesh after Unity has re-rendered those in the atlas...

    But then there's a problemous situation - what if there is very many different Dynamic Text objects and they all need their text in different presumably large sizes (same also applies to Text Mesh/other Unity Font-using system), immediately filling up the atlas again, leading to a reset of it, trying all over again ... at that point we hit the impossible situation and its graceful fallback. Dynamic Text detects this and reduces the actual pixel size used for text at loss of some visual quality, but that should keep the app running instead of hanging completely.

    The thing here is that it's not really helping if the device has much memory, since this is about what is the maximum size for font atlas texture (supported by Unity, or what is supported by hardware). Also, Unity Font system doesn't split the font atlas to several different textures, so those are just hard limits we have to live with.

    I wanted to give some context of why this happens, but here's of course some actual things you can do:
    • Check out what "Metrics Ref Chars" of all your Dynamic Text objects has. If you have used some earlier versions, then there's a long list of characters (all through a...z, A...Z and 0...9). The metrics ref chars is a list which ones should be always available, i.e. taken into account when measuring text baseline/ascent/descent - but all of those are also always rendered to the font atlas texture. In later versions I reduced the default amount of characters a lot. You can reduce that even further, perhaps adding only characters "xjl".
    • Design for using less text which is very large.
    • Try to use less different text sizes (or with perspective camera, just different distances to it, since for dynamic text the actual final text on screen is what defines if it's different size).
    • For less important text (and especially ones which are large), set manually the "Max Font Px Size" to smaller value.
    • And, very importantly, try not to change the text size "smoothly" with a script (to use a scale/zoom transition for example) -- this also means that for perspective cameras, try not to change text distance to camera smoothly over time. In this case all the intermediate text sizes will need to be added to the font atlas. If there's many text instances with different sizes and this kind of size-changing going on, at least that is a very probable way of hitting the problem you're describing.
    • Adding to that last point -- If you really want to e.g. have an effect with a text zooming close to camera or something, then I recommend you accept that it's not that good looking near camera, and set the Max Font Px Size to a smaller value. Or alternatively use the built-in Text Mesh (3D Text) for that particular thing, which doesn't dynamically render the text in different sizes at all (but often looks a bit jaggy/blurry).
    Hope this helps you to understand the situation and reduce this problem happening to you!
     
  34. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Hello,

    I have a question about using Dynamic Text in a 2D game. I'm using it on top of a billboard, which is a sprite. Everything works fine if the sprite is placed in the Default sorting layer. If the layer is changed to a "higher" one, text becomes invisible. I followed your advice on this forum and used

    ...GetComponent<DynamicText>().sortingLayerName = ...
    and
    ...GetComponent<DynamicText>().renderer.sortingOrder = 1;

    So, it works great. The only inconvenience is that this obviously doesn't solve the issue inside the Editor and I need to switch between sorting layers when tweaking fonts, layout, etc.

    Is there any way to assign Dynamic Text to a sorting layer and if not, are there plans to add this ability in the future?

    Thanks!
     
  35. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @username132323232.

    You have two options to work around that:

    1) Put all your sprites to another sorting layer which is behind the Default one. (Click Sorting Layer, "Add Sorting Layer...", make a new one with e.g. name "behind" and then drag it to be above Default one in the order).

    2) Modify the script which you use to set Dynamic Text sortingOrder to run in ExecuteInEditMode, e.g. something like this:
    Code (CSharp):
    1. // SetDynamicTextSortingOrder.cs
    2. using UnityEngine;
    3. [ExecuteInEditMode]
    4. public class SetDynamicTextSortingOrder : MonoBehaviour
    5. {
    6.     public int sortingOrder = 1;
    7.  
    8.     void Update () {
    9.         GetComponent<DynamicText>().renderer.sortingOrder = sortingOrder;
    10.     }
    11. }
    (Hint: you might also want to do the assignment also in Start() and have the Update() wrapped in #if UNITY_EDITOR ... #endif or something, so that it will keep changing that all the time only when running in editor...)
     
    username132323232 likes this.
  36. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    The second option worked perfectly. Thank you so much for the wonderful plugin and for first-rate user support!
     
  37. Rutty03153

    Rutty03153

    Joined:
    Nov 21, 2013
    Posts:
    5
    We've been using your plugin for a while and it's worked brilliantly for us, however we recently made the move for one project to Unity5, we can see you're aware there are currently problems, the main one for us is that it appears to be doing the pixel snap 'dance' constantly, even when pixel snap is disabled. Is this a known bug and if so do you have any idea when you'll be able to update with a fix for this? Thanks
     
  38. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Rutty03153! Nice to hear you like Dynamic Text.

    If the text keeps moving a bit even if turning off the pixel snapping, that sounds like it might not actually be an issue from upgrading to Unity 5 but instead maybe about using some own layouting / alignment code combined with Dynamic Text?

    I have done only limited testing with DT & Unity 5 so far, so of course it could also be some new issue I was not yet aware of.

    However, there is one entry in the FAQ about issue like you're describing - I'll quote from there:

    I have some of my own custom UI movement/alignment code. Pixel snapping "fights" with it, moving each frame. How can I fix this?
    Move the DynamicText down in scene hierarchy so that it's a child of the object having your code (which has custom movement).​

    So, can you please check if that fixes your issue (for example if you have some custom code which tries to align a dynamic text entry to be relative with some other component, or just moves the game object in some way).
     
  39. Erhune

    Erhune

    Joined:
    Sep 12, 2012
    Posts:
    7
    I am encountering a new issue since migrating my project to Unity 5.

    I use Visual Studio 2013 with the UnityVS plugin, and when I try to compile the project from Visual Studio, I get the following error for each usage of a DynamicText variable:

    The type or namespace name 'DynamicText' could not be found (are you missing a using directive or an assembly reference?)

    I have confirmed that this is the case using a very simple Unity 5 project with ONLY DynamicText and UnityVS imported.

    The issue seems to be with Microsoft compiler not liking something in DynamicText.dll, since both my real project and my test project compile and work fine inside of Unity.
     
  40. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @Erhune. Thanks for the report.

    I can reproduce the issue but can't figure out the problem and a fix to it right away.

    I'll try to find a fix as soon as possible.
     
  41. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @Erhune - when only looking at viewpoint of Visual Studio, this issue seems to manifest if the DLL has been upgraded by Unity 5 after which it thinks the dll requires .net target framework 4.0 although the VS project files are set to target .net version 3.5 instead.

    It seems to work if you manually change the Target framework to ".NET Framework 4" in VS project properties, for each of the open project files. Unfortunately that manual change is always lost when Unity or UnityVS re-generates the VS projects.

    It seems that using a DLL built directly to Unity 5 (targeting .NET 3.5) works without this issue. So apparently there's something weird going on in Unity 5's API auto-updater when it writes a new DLL.

    If you want to test a version of Dynamic Text DLL built for Unity 5 (very minimally tested), send me a PM or email contact (at) strobotnik dot com, along with your OR123456789-like order number.
     
  42. Rutty03153

    Rutty03153

    Joined:
    Nov 21, 2013
    Posts:
    5
    Thanks for the advice but we've not got movement scripts any differently set up to how they are in Unity 4 where the problem doesn't occur and all objects are set up according to your advice as well with object movement occurring one or two levels higher than the text. As previously mentioned my bigger issue is this occurs when pixel snap is turned off entirely on every instance of DynamicText, at which point your script shouldn't be 'fighting' ours, should it?
     
  43. Erhune

    Erhune

    Joined:
    Sep 12, 2012
    Posts:
    7
    Good find!

    For now, I've added an fake DynamicClass in my project that is #ifdef-ed away when compiling with Mono, so this fixes my immediate issues (I don't really care about the result of the Visual Studio build, I just need it to compile to ensure that I don't make other mistakes).

    Thanks for the investigation, and hopefully Unity will fix that on their side... (I didn't have a similar issue with other auto-updated dll though, it must be a specific combination of things that makes the auto-upgrader misbehave...)
     
  44. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    @Rutty03153, okay I see. Can't directly think what would be the cause in this case (unless I've made some embarrassing regression bug). Would it be possible for you to set up a mini test scene where that happens?
     
  45. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Hi Tonic,

    I would like to have a rotating cube with text on one of the faces. The cube is not transparent. If I attach a Dynamic Text object to the cube, it's visible all the time, even when it's on the opposite to the camera side. I would like it to behave in a more realistic way and become invisible when the cube is turned. I did some more testing and realized that Dynamic Text is never blocked, at least the way I use it. Am I missing something obvious?
     
  46. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi! Normally Dynamic Text uses the same default material/shader than built-in Text Mesh objects use, and that works the way you describe. Additionally, I don't advise to use Dynamic Text in such a case, since the main use case for it is meant to be one where the text faces directly the camera. Text attached to a rotating cube will need frequent updates to texture atlas, so performance of such case is not as good as camera-facing text which is "mostly static".

    However I can still give info how to do what you want.

    But you can switch to a custom material (with a different shader). See this wiki page for example of the type of shader you probably want: http://wiki.unity3d.com/index.php?title=3DText

    To correctly set up the new material you probably need to use a custom font so you get the chance to drag the font texture to the material (I don't remember if there was a way to do that in the editor for the default Arial font .. although it should be possible, at least with some script code).

    Follow these steps:
    1. Create a new material, let's call it testtextmat.
    2. Select your new material and select the custom text shader you want to use (the default text shader would be GUI/Text Shader, but you want e.g. the GUI/3D Text Shader from the above wiki link).
    3. Keep the testtextmat selected. Find the font you want to use in Project view, and expand the little arrow of the font. Then drag the Font Texture from there to the Font Texture slot of testtextmat. For example, try this with the DroidSans font in DynamicText/Examples/ExampleHelpers.
    4. For next steps, select your Dynamic Text game object in the Hierarchy view so we can do stuff to it in the Inspector. Let's call your object DynText.
    5. Turn off "Auto Set Font Material" in DynText.
    6. Drag the correct font to the "Font" slot of DynText - for example drag the DroidSans from Project view there.
    7. Drag testtextmat over the existing Font Material in Mesh Renderer of DynText (replace the material).
    Now it should work. Just remember to update all the pieces by that list if you change to different font for example, otherwise text can't be seen or will become garbled.
     
    username132323232 likes this.
  47. username132323232

    username132323232

    Joined:
    Dec 9, 2014
    Posts:
    477
    Thank you for such a thorough answer! The steps that you suggested worked great.
     
  48. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    Hi,

    I have another issue with Unity 5 p3. I have the exception commented on this thread:

    http://forum.unity3d.com/threads/ios-crash-after-applying-patch-p3-unity-5.314139/

    In the other hand, I have the following warning in editor mode:

    Object has zero scale - Not snapping (this warning is logged only once even if problem persists)
    UnityEngine.Debug:LogWarning(Object, Object)
    DynamicText:e()
    DynamicText:GenerateMesh()
    DynamicText:FinishedTextSB()
    DynamicText:SetText(String)
    DynamicText:g()
    DynamicText:Awake()
    UnityEngine.Object:Instantiate(Object, Vector3, Quaternion)
    ...

    What do you think about? Do you have any clue about what's wrong?

    Thank you in advance
    Antonio
     
  49. aparraga

    aparraga

    Joined:
    Aug 13, 2014
    Posts:
    20
    I have fix the problem if I initialize the dynamic text to " " (one space). The problem happens if the initial string is empty ("")
     
  50. tonic

    tonic

    Joined:
    Oct 31, 2012
    Posts:
    439
    Hi @aparraga, thank you very much for the bug report and your workaround. I think that should be very helpful in finding any problem & fixing this for next release. (First I though it might be just a problem in batching of Unity 5p3 itself, but it sounds like I should double check what DT-generated mesh contains when set to empty string.)