Search Unity

TEXDraw - Create Math Expressions inside Unity!

Discussion in 'Assets and Asset Store' started by WillNode, Jan 13, 2016.

  1. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    It will automatically adjust, based on UI Canvas scaleFactor. Or go to TEXConfiguration (Menu Tools, TEXDraw, Open Preference, Config) and set document retinaRatio higher.

    I didn't aware that. You can go to TEXConfiguration and set typeface line ascent lower.
     
  2. L_A_R

    L_A_R

    Joined:
    May 14, 2017
    Posts:
    34
    Hi is there any update on the official release? I am looking to release an app within the next few weeks and have to have the text auto-resizing feature.
    Thanks
     
  3. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    No launch date yet. But I believe it's pretty much stable.

    Uhh, looks like I can't finish the other feature yet. Maybe I should push releases more often.
     
  4. L_A_R

    L_A_R

    Joined:
    May 14, 2017
    Posts:
    34
    A release that includes auto-resizing if it's stable and ready anyway would be massively appreciated if possible!
     
    Last edited: Mar 16, 2021
  5. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi WillNode, I wrote you an email but if in doubt I write you here too, I copy the text of the email:

    "There is one thing that I am banging my head on and I cannot figure out how to get out of it, which is the system of spaces close to the equal of the equation.

    I am attaching two screenshots to be clear, in the first you can see how the equation "ax = b" is written well aesthetically. In the second, however, that is "ax = -b" the "-" is visually too close to the equal, and I don't understand why, is it a bug? Was I wrong to implement it?"
     

    Attached Files:

    • 1.png
      1.png
      File size:
      40.7 KB
      Views:
      305
    • 2.png
      2.png
      File size:
      48.7 KB
      Views:
      318
  6. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    You're not wrong, but it's something that even the LaTeX forum can't give a nice answer for.

    If you scroll down to that page, you can see that LaTeX recognize minus in $-16$ as negative sign, while ${}-16$ recognize it as a minus operator. TEXDraw does that too.

    So your best bet right now is nest the math expression. Like this:

    Code (CSharp):
    1. \(ax=\(-b\)\)
    2.  
    3. \(\frac{ax}{a}=\(-\frac{b}{a}\)\)
    upload_2021-6-25_4-7-15.png

    Note: The \(...\) (and \[...\]) is the LaTeX way instead the traditional $...$ and $$...$$
     
  7. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Yes, it works, the problem is that it is not very readable at the beginning (the code) (maybe because I'm not used to it yet).

    In the meantime I have found this further solution (adding a space before and after the equal with "\,"), is it acceptable?

    Code (CSharp):
    1. $ ax \, = \, -b $
    2.  
    3. $ \frac{ax}{a} \, = \, - \frac{b}{a} $
     

    Attached Files:

    • 3.png
      3.png
      File size:
      42.7 KB
      Views:
      301
  8. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    It is a valid LaTeX, but you might want to utilize the "glue matrix" in TEXPreference. It's the thing that responsible to give different spaces between math expressions. The default values are from "the TeXbook" by the inventor of TeX.

    upload_2021-6-26_0-21-33.png

    If you just want to enlarge all the glues, head to "Glue Ratio" in TEXConfiguration.

    As far as I can tell, the early versions of TEXDraw actually doesn't follow LaTeX at all. It was simple, but it won't cut corner cases that I found out in later developments. So yeah, it somewhat verbose, but LaTeX works great in the end anyway, that was motivates me to rewrite the whole thing in the past too.
     
  9. ChicagoCenterForMathematics

    ChicagoCenterForMathematics

    Joined:
    May 24, 2021
    Posts:
    3
    Hi. I'm building a presentation using TEXDraw. It's a very nice package overall, but I'm having an issue and I could use some help.

    When I use the boldface font style it does not always render correctly. For example, when I write the title of the presentation as {\bf Practice Quiz} in the TEXDraw UI component, sometimes it appears scrambled and sometimes it does not appear at all.

    This happens in the editor and also in builds. In editor I can fix this by rebuilding TEXDraw on scene. I haven't found a way to fix this in builds.

    Any help?
     
  10. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    This is a known issue. You can enable TMP Integration so the rendering will be more consistent.
     
  11. ChicagoCenterForMathematics

    ChicagoCenterForMathematics

    Joined:
    May 24, 2021
    Posts:
    3
    Thanks! It's working now.

    I just finished making a Beamer style presentation using TEXDraw. It looks great! I'm excited to use this asset more.

    I uploaded a video of my presentation to YouTube. Is it okay to post a link to my video here? I'm using the video to promote my tutoring business, so it could be seen as self promotion.
     
  12. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    No problem at all :)
     
  13. ChicagoCenterForMathematics

    ChicagoCenterForMathematics

    Joined:
    May 24, 2021
    Posts:
    3
    Here's a link to a presentation I made using TEXDraw. I'm really happy with how it turned it. Thank you!

     
    WillNode likes this.
  14. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Possible solution to the problem I mentioned earlier (the signs '-' near to the equal): bring the value (operator-relation) to the same value as (ordinary-relation) in the "Glue Matrix", acceptable?

    I wonder why it seems to solve the problem without causing others, but if the inventor of TeX put it this way maybe there is a reason, I would not like to stumble into a simple mistake.
     
  15. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Well, the TeXBook (page 170) puts the Glue matrix value op-rel and ord-rel the same. Does it come different? Looks like it is something I need to fix.


    upload_2021-7-17_6-56-19.png
     
  16. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Ah here it makes sense now. Do you seem to have forgotten (at least) that value?
    I tried to create a new project and added the latest patch you sent me. Here is the Glue Matrix.

    Now at my place it is two in the morning and I am not lucid to be able to compare the tables which are also backwards hahaha. Try to compare them and tell us.

    Image 1.png Image 2.png
     
  17. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Also every time I close and open the project it resets the values. I am unable to keep the changes. What's new about the solution?
     
  18. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Whoa, so much stuff we've been discussing around in email. thanks.

    ---

    For else who read this thread, there has been significant improvement and bug fixes in the Git repo that I haven't released yet. If you having some small issues with TEXDraw, it might be better to try the bleeding edge version right from the Git repo. I plan to release the new version around next month.
     
  19. wadyaruss

    wadyaruss

    Joined:
    Jul 31, 2020
    Posts:
    3
    sometimes it shows like that (20% times), can change in play-pause-play mode in unity
     

    Attached Files:

  20. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Hi, you're setting the resolution/font size too high. Try to reduce it until it's good enough or enable TMP integration.
     
  21. wadyaruss

    wadyaruss

    Joined:
    Jul 31, 2020
    Posts:
    3
    I change it to 100 (i need big numbers), but it still crushes sometimes...
    What is the best font size for 100% working?
     
  22. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Any font size is optimal because if you make it large, the overall text size is larger too. TEXDraw UI behaves just like regular text and it will match the resolution on the screen.

    If you want it larger because of High DPI/retina displays you can increase the retina ratio to 2 or something.

    upload_2021-7-31_6-48-33.png
     
  23. AC_GameDev

    AC_GameDev

    Joined:
    Sep 27, 2018
    Posts:
    6
    I need to display a blank in question text but am having trouble getting this to work. An example would be something like "Kitten is to cat as puppy is to _____?"

    Problem is that TEXDraw displays _____ by taking the previous word and displacing it below the main line of text. I tried using the \_ code either alone or in a sequence like \_\_\_ but it just gives me a single dot or a series of dots at the top of the line. How can I display a blank like I am currently trying to?
     
  24. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    The syntax \_ is correct but LaTeX fonts don't provide underscore characters so you need to use regular fonts like Open Sans (provided as \opens). To be clear, this will works:

    \opens{Kitten is to cat as puppy is to \_\_\_\_\_?}

    You can also open the config and set Default Typeface to `opens` to make \opens the default.
     
  25. AC_GameDev

    AC_GameDev

    Joined:
    Sep 27, 2018
    Posts:
    6
    Thank you very much for the response!
     
  26. VishweshVichu

    VishweshVichu

    Joined:
    Oct 31, 2017
    Posts:
    4
    Does this asset support TMPro as well?
     
  27. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Sorry missed your part. Yes, it is. Just to be clear It supports TMPro rendering in TEXDraw, but it will not extend TMPro existing functionality.
     
  28. VishweshVichu

    VishweshVichu

    Joined:
    Oct 31, 2017
    Posts:
    4
    I'm not getting it completely. What do you mean by TMPro Rendering in TEXDraw here?
    Can you elaborate a bit? An example screenshot would be more helpful

    Cheers,
    Vishwesh
     
  29. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I believe he refers to the conversion of normal .ttf Text fonts into TMPro's .asset fonts which guarantees better graphics.
     
  30. chabin

    chabin

    Joined:
    Jul 31, 2012
    Posts:
    2
    I'm working on tools to help kids think quantitatively and TexDraw is fabulous. I feel like an idiot but for example, if I write {\bf some} text to a field, wait a few seconds, then write something else, the word "text" persists. Similarly, if I write {$2\over3$}, I get a beautifully formatted fraction, but the fraction bar persists when I write new text into the field. {\blacktriangle} creates a filled in triangle and \Delta produces the Greek letter, but the triangle persists and the delta does not.

    I'm sure I'm doing something dumb, but I've spent hours. The expressions seem to be legal when I try them in the demos, but parts of them don't go away when I write over the field. The TexDraw documentation is great, but I think it assumes I know more than I do. Am I missing something simple or is there a resource I should know about.

    Thanks so much!
     
  31. Unknown_Oleg

    Unknown_Oleg

    Joined:
    Oct 19, 2019
    Posts:
    7
    Hi ! We are trying to use styles in this plugin, but they don't work. What could be the problem? If you add a tag \bf or something else in the TEXDraw UI component, the word in front of it just disappears ??
     
  32. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Still works to me...

    upload_2021-9-24_16-45-24.png

    Fonts disappear usually because TEXDraw's font size is too large. In that situation it's better to enable TextMeshPro integration.
     
  33. Unknown_Oleg

    Unknown_Oleg

    Joined:
    Oct 19, 2019
    Posts:
    7
    Why it is so not intuitive, I cannot understand how it works. In the help, add "\ bf" - how, where? i tried before word, after, between open and closed tag.
    How do I make the text bold? I didn't find the "opens" tag in your help, what does it mean?
     
  34. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I admit the documentation is not complete enough. Sorry for that.

    \bf and other text modifiers affects characters after that unless it's directly followed with group braces {}. That's just how LaTeX works. If you have followed the example above but have different result instead, it's probably a bug.

    \opens means "open sans", it changes the font family used.
     
  35. AC_GameDev

    AC_GameDev

    Joined:
    Sep 27, 2018
    Posts:
    6
    I'm having an issue where TexDraw elements are glitching out. This happens when I save the Unity scene in the editor but we're also having a problem with it in the live build. In the editor I can simply rebuild TexDraw data in the scene with Ctrl+Alt+R but I can't just do this in the build. Is there a method I can call from a script that rebuilds TexDraw once I've loaded new text into the UI element?

    Something like "TexDrawLib.Rebuild()?"
     
  36. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    There is one function in the library that does it,
    TEXDrawPreference.main.CallRedraw()
    but it's editor only.

    You can build your own function from that.

    Code (CSharp):
    1.             Component[] tex = FindObjectsOfType<Component>();
    2.             for (int i = 0; i < tex.Length; i++)
    3.             {
    4.                 if (tex is ITEXDraw)
    5.                 {
    6.                     ((ITEXDraw)tex).SetTextDirty();
    7.                 }
    8.             }
     
  37. Appopiss

    Appopiss

    Joined:
    Mar 25, 2019
    Posts:
    1
    Hello, I started to use this asset to make a kind of math game and this is really great!
    Thank you for making this :D

    So, I would like to ask if I can get the position of each characters in a TEXDraw text (by Vector3). What I really want to do is to make some pop up window appear when you hover any term in the text.
    For example, assume that there's a text "y = ax" and when you hover the mouse on "a" in the text, then I want to make some pop up window show up saying "a = 0.01".

    Seems that TextMeshProUGUI provides a function to get character's position through TMP_TextInfo class to realize that.

    Could you tell me any idea about it?
    Thank you very much!
     
  38. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I should really write a documentation about it.

    The closest thing that can provide this is TEXInput. You need to read the code when the mouse in clicking, etc. Or if you only need specific portion you can use \link and read the rectangle boundary the way TEXLink does.
     
  39. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Anyway, TEXDraw 5.6 has just been uploaded and should be available in asset store in few days. It features builtin unicode to latex converter so you can just write unicode symbols and not having to deal with latex syntax ;)
     
  40. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Downloaded TEXTDraw 5.6, the unicode conversion makes everything more intuitive, good.

    I report that (∙) is translated incorrectly (I think \cdot is the correct translation, I had written it in an old mail but perhaps you have forgotten it) and that these characters do not recognize them (Á, É), in particular the first is incorrectly translated, while the latter directly causes exceptions.

    image.png
     
  41. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Thanks for the finding. I admit this feature is quite new, and no "canon" reference I can found so I can only fix it by bug reports. I may create small patches in the future as more reports come in.
     
    Francesco-FL likes this.
  42. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    No problem. If I find anything else, I will gladly report it to you
     
    WillNode likes this.
  43. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I made a small list of characters that I might need in the future so you don't have to add them from time to time, I found these:

    Greek letters: "Μ,Ν,Ο,ο,Υ,Ω"
    Accented letter: "ó"
    Symbols: "%,‱,√,∈,∖ (This character is not a backslash but the '-' symbol for sets)"

    I don't know if I already asked you, but do you know if there is a unicode for symbols like (\leqslant, \geqslant)?

    ps. I wrote you an email, check as soon as you can
     
    Last edited: Nov 2, 2021
  44. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I'll check that. But do you know the % sign is used as a beginning of a comment in TeX?

    I have updated the symbols page to include Unicode characters. Still a work in progress.
     
  45. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    I didn't know about the %, good to know, I'll use \% which is shown correctly.

    For symbols such as ⩾ unfortunately some are not recognized in the editor and become an invisible space (ie if you copy for example the '⩾' symbol in TEXDraw it appears in the scene but not in the inspector). I had already reported this problem to Unity, but the bug is still active, I think we will have to wait (https://issuetracker.unity3d.com/issues/text-unrecognizable-character-appears-as-invisible-space) (I wrote this just to let you know they have a recognized bug about it)

    When you have fixed the space problem I emailed you, send me the fix if you can.
     
  46. tylkomat

    tylkomat

    Joined:
    Jun 17, 2019
    Posts:
    22
    Hello WillNode,
    is it possible to have the lines in
    \itemize
    indented, like in the right side of my image?

    itemize.png
     
  47. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Not possible yet, I add this to the backlog.
     
  48. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Hi,

    I just wanted to give you some updates regarding the latest changes made in TEXDraw.

    I wanted to plan a release since the last month, but holding it instead since I wanted to fix all inconsistencies in TEXDraw according to user feedback you've all made. If you've been eagerly wanting these changes, go grab them in the GitLab repo. I try my best to release in the upcoming days before new year's eve.

    Thanks and happy Christmas!

    upload_2021-12-24_19-12-55.png
     
    tylkomat and Francesco-FL like this.
  49. UnityedWeStand

    UnityedWeStand

    Joined:
    Dec 16, 2018
    Posts:
    1
    Hello WillNode,

    Just purchased TexDraw yesterday, everything seems great except I can't get \langle and \rangle to show for some reason. See attached screenshot (Unity version is in the displayed in upper right). Have tried rebuilding fonts, directly pasting unicode, adding \left and \right, restarting Unity, etc.

    upload_2021-12-29_16-20-26.png
     
  50. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    A new version is coming to fix this problem.

    You can shoot me an email and I will send the new version (or you can just download it from the GitLab repo)
     
    UnityedWeStand likes this.