Search Unity

FlyingText3D - Real dynamic 3D text from TrueType fonts

Discussion in 'Assets and Asset Store' started by Eric5h5, Jun 11, 2012.

  1. Michael_Squiers

    Michael_Squiers

    Joined:
    Nov 6, 2014
    Posts:
    29
    Hi,
    I use Vectrosity to create an InputField Box. The text child of the input field is set to Horizontal Overflow Wrap and Vertical Overflow Truncate. After the user finishes typing and clicks off the InputField Box, I hide the box and take the text from it and place it as 3D text into the scene. If I manually hit enter it works perfectly but if the text was resized to best fit or goes to a newline it doesn't work. The 3D text just appears as one straight line instead of the block of text in the InputField. How would I go about getting the 3D text to match what was in the InputField.

    Thanks Again,
    Ive bought most of your assets, Keep up the good work.
     
  2. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    You can use the line width and word wrap settings in FlyingText, so you would have to find some way for those settings to have the same results as the input field settings. Unless there's some way to access the raw text, so you'd know where to put line endings in the 3D text.

    --Eric
     
  3. tosi

    tosi

    Joined:
    Jul 5, 2012
    Posts:
    45
    Hey there,

    I have a problem with the Flying Text Plugin using a special font of our customer. It works with other fonts, but not with the one I am told to use. So, I am fully aware of the fact, that the problem might not be the plugin, but the font. However, maybe you can help me find out what exactly is wrong with the font.
    The error I get in Unity is:
    NullReferenceException: Object reference not set to an instance of an object
    FlyingText.GetObject (System.String s, UnityEngine.Material material, UnityEngine.Material edgeMaterial, Single size, Single extrudeDepth, Int32 resolution, Single characterSpacing, Single lineSpacing, Single lineWidth, Boolean prime, Boolean separateObjects, Boolean useObjectsArray, Vector3 position, Quaternion rotation, UnityEngine.GameObject gObject) (at Assets/Plugins/FlyingText/FlyingText.cs:638)

    It occurs if I use the Create Flying Text object utility with the string "e".

    Line 638 is the third line in this code:
    Code (CSharp):
    1. int thisGlyphIdx = glyphIndices[i];
    2. if (!verticalLayout) {
    3.     horizontalPosition -= thisFont.lsbArray[thisGlyphIdx] * scaleFactor;
    4. }
    Unfortunately, I can't give away the font. The project, I am working on is under NDA.
    But, the font is 25MB in size and contains also asian characters.
    I opened the font in a tool called FontForge. It has a validation feature, that tells me the following about the font:
    • self intersecting
    • wrong direction
    • missing points at extrema
    Can one of these lead to an error in the plugin like mentioned above?
     
  4. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    I don't think it should get a null reference exception (although maybe the "missing points at extrema" is doing that?). It wouldn't work anyway, though, because of the self intersecting. There's not much I can do about that, sorry; self intersecting works OK when a font is converted to a bitmap for display, but would make converting to a mesh significantly more difficult. If there's some way you can use an edited version of the font, where the "e" is fixed, that should take care of it.

    --Eric
     
  5. tosi

    tosi

    Joined:
    Jul 5, 2012
    Posts:
    45
    Thank you for your answer.
    The problem is not the "e" itself. I should have make that clear, sorry. Something with the font might be so terribly wrong, that even if I just want to generate "e", it crashes.
    I further examined the other font , that works. It also has missing points at extrema and self intersections. Flying Text is even able to generate these corrupted letters of this other font. This is so strange. I now ended up leaving only the needed characters in the desired font and deleted all others. Now the font is of a usual 150K size and Flying Text is working. For the current phase of the project, this is sufficient.
     
  6. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    Sounds like a bug in FlyingText3D; I'll look at the code and see what I can do, though it would be easier if I had the font (I realize you can't give it to me).

    --Eric
     
  7. xpkoalz

    xpkoalz

    Joined:
    May 31, 2014
    Posts:
    11
    Hi
    for the Demo examples, are there any scripts written in c#? Currently its all .js and pdf documentation is in .js as well.
     
  8. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    The code examples in the docs are intended to be both Unityscript and C#, though in some cases I didn't properly execute that (i.e., "30.0" instead of "30.0f", but in any cases the differences are trivial).

    --Eric
     
  9. xpkoalz

    xpkoalz

    Joined:
    May 31, 2014
    Posts:
    11
    thank you for replying. figured out how to use it. sorry for question. will let you know if i face any other problems. :)
     
  10. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    I'm getting the error now, using FlyingText3d in a project. Worked fine last summer in Unity 5.1, but now in 5.3.4, I get this error. The Asset Store doesn't say I should upgrade, so I guess I have the latest version.

    InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method: 3D Text Generator. Notice that DontDestroyOnLoad can only be used in play mode and, as such, cannot be part of an editor script.
    FlyingText.Initialize ()
     
  11. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    Strange, that doesn't happen here, or in Unity 5.4 either. But you could use the source, and replace the DontDestroyOnLoad line with this:

    Code (csharp):
    1.         if (Application.isPlaying) {
    2.             DontDestroyOnLoad (this);
    3.         }
    --Eric
     
  12. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    Thanks, but where is that? I imported the source but can't find "destroy" in any of the scripts.

    So then I deleted all the FlyingText stuff from the project, and imported it fresh, but then I get compiler errors, even after deleting all the Demo folders.

    And now I've created a fresh project and imported FlyingText, and again I get the DontDestroy error. Then I imported the Source package...and now I get all those compiler errors again. I'm using 5.3.4f1.
     

    Attached Files:

  13. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    Sorry, in the FlyingText script, at the bottom of the Initialize method. When importing the source, you need to remove the dll.

    --Eric
     
  14. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    Sorry, I must be an idiot (and I'm definitely not a programmer), but I can't find "init" or "destroy" in FlyingText.cs. See screenshot--is this the correct file?
     

    Attached Files:

  15. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    Yes, that's correct. At the bottom of the Initialize function, which is the first function in the file. It's not "destroy", it's DontDestroyOnLoad.

    --Eric
     
  16. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    Well, that's weird -- Search function in Unitron wasn't working, so searching for "destroy" or "init" found nothing. Weird. But now I've added that code, but get the same error. Sorry to be an idiot/pest, but what am I doing wrong now?

    Here's what I've got:

    _colorDictionary = new Dictionary<string, Color32>(){{"red", Color.red}, {"green", Color.green}, {"blue", Color.blue}, {"white", Color.white}, {"black", Color.black}, {"yellow", Color.yellow}, {"cyan", Color.cyan}, {"magenta", Color.magenta}, {"gray", Color.gray}, {"grey", Color.grey}};
    if (Application.isPlaying) {
    DontDestroyOnLoad (this);
    }
    _initialized = true;
     
  17. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    I don't really have any other suggestions, sorry, except maybe the error is somewhere else. If you changed the code like I showed, then it's not possible for DontDestroyOnLoad to be executed in edit mode, so the error couldn't occur. Like I said, it doesn't happen with Unity 5.3 or Unity 5.4 here, even without changing the code; also nobody else has reported any similar errors. By the way, the version in the store is 2.2, and you appear to be using 2.1.2.

    --Eric
     
  18. gecko

    gecko

    Joined:
    Aug 10, 2006
    Posts:
    2,024
    Weird, I had to dig into my system stuff to delete the old FlyingText package, since the Asset Store was sure I did not need to Update. Now, after installing the source and making that edit, it works. Whew! Thanks for your help.
     
  19. neonyourself

    neonyourself

    Joined:
    Dec 12, 2013
    Posts:
    5
    Hi

    We are seeing the same issue as above - just downloaded it. Error: InvalidOperationException: The following game object is invoking the DontDestroyOnLoad method

    It says it is version 2.2 and Unity is 5.3.4. Where do you install the source from?

    Regards
     
  20. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    From the package called FlyingText3D_Source.

    --Eric
     
  21. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    A small update is out (2.2.1), which fixes the Unity 5.4 error. (Still needs to be approved for the Unity asset store.)

    --Eric
     
  22. seijik42

    seijik42

    Joined:
    Sep 8, 2013
    Posts:
    5
    Hi, I'm considering to buy this asset. Bevel feature is not supported yet?
     
  23. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    No, sorry.

    --Eric
     
  24. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    47
    Hello Eric,
    is it possible to load a font at runtime from the storage and use it? In the documentation i didn't find anything for changing the font. Only seting the font index for fonts that are set in the inspector
     
  25. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    No, the fonts have to be in the Unity project.

    --Eric
     
  26. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    47
    Can i do anything to get this to work at runtime? For me the asset is pretty much useless if you can't pick a font at runtime :(
     
  27. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    It's theoretically possible but would require some re-programming. How about including a selection of fonts in your app that the user can pick from?

    --Eric
     
  28. look001

    look001

    Joined:
    Mar 23, 2017
    Posts:
    47
    That is not an option. I want the user to pick a custom font. Can i do the re-programming myself?
     
  29. Eric5h5

    Eric5h5

    Volunteer Moderator Moderator

    Joined:
    Jul 19, 2006
    Posts:
    32,145
    Sure, you have the source code; indeed that's what it's for.

    --Eric