Search Unity

TEXDraw - Create Math Expressions inside Unity!

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

  1. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Tell me if I did something wrong.

    1. Characters are shrunk if $ is used, and corrected if $$ is used (I only use one $)
    1.png
    2.png

    2. Glue Matrix values support lower values than last version. For example, I used 5 for "Relations", and now the maximum is 3 and I would like to put it at 5 as before.

    3. ^ doesn't work sometimes in roots (and maybe other functions)
    3.png

    4. Now the tables have very close rows compared to before, I was wondering if there was something to change to enlarge them
    4.png
     
  2. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Wow, I didn't see that questions coming. I'm about to announce the v6.0 release haha.
    For readers, v6.x is the release where I start to achieve the closest I can to bring TEXDraw to the "true" LaTeX syntax. This release brings so much change there may be some adjustments needed in an existing project. This particular v6.0.x release is stated as BETA until I have completely finished writing the documentation.

    This is now expected. $ is an inlined math style, some areas (particularly fraction and roots) will be shown shrink. This can be observed in MathJax by prepending \textstyle. You also can prepend \displaystyle in TEXDraw to enforce inline math to be displayed as block math.

    It has been replaced by thin, medium, and thick glue (1, 2, 3 in the glue matrix) to match with TeX behavior. You can change the thick (or medium or thin) glue width in TEXConfiguration values (they are now separate values each while previously is just a simple multiplication, which is wrong).

    I will investigate

    That's my mistake. I incorrectly set cell padding as line width. It should be frame padding. Will create a new release that fixes it.
     
    Francesco-FL likes this.
  3. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    I'm getting some strange behavior with matrices, is this a known issue?

    code:
    Code (csharp):
    1. \bold P(t)=
    2. \begin{bmatrix}
    3. 1 &t &t^2 &t^3
    4. \end{bmatrix}
    5.  
    6. \begin{bmatrix}
    7. 1& 0& 0& 0\\
    8. -3& 3& 0& 0\\
    9. 3& -6& 3& 0\\
    10. -1& 3& -3& 1\\
    11. \end{bmatrix}
    12.  
    13. \begin{bmatrix}
    14. P_0\\
    15. P_1\\
    16. P_2\\
    17. P_3
    18. \end{bmatrix}

    Expected output (rendered in Notion's /math block):
    upload_2022-1-6_15-52-25.png

    TEXDraw:
    upload_2022-1-6_15-51-56.png

    edit: here's a more simple case that also seems to break (now with TMP enabled):

    \begin{bmatrix}a b c\end{bmatrix}


    upload_2022-1-6_16-13-25.png
     
    Last edited: Jan 6, 2022
  4. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I didn't know that. Let me check for a while.
     
    Acegikmo likes this.
  5. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I have fixed it in the latest commit. you can download the fixed version from GitLab or ask me by email to send it (or wait for a new release on weekend?).

    I have checked this, and it only happens if TMP rendering is set to dynamic. The old method (static rendering mode) has no problem.

    It looks like I missing something important in the TMP rendering code. This one takes longer to fix.

    For a temporary workaround, you can disable TMP rendering, delete TEXDraw/Fonts/TMPro folder, and re-enable TMP with static rendering mode.
     
  6. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    hm, I requested access, it said it succeeded, but I don't see an invite notification on gitlab, and I don't know if I'm supposed to be able to see commits or not (I don't really use gitlab! until now~). because I can't see the commits or any kind of pull/clone button, just the issues list basically!
     
  7. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    My bad. I haven't updated the system for years. I have added you in manually (your ID on GitLab is the same as here, right?). You should see the repository files from now on.
     
  8. Francesco-FL

    Francesco-FL

    Joined:
    May 25, 2021
    Posts:
    176
    Hi

    1 - Real superscripts and subscripts don't work as TEXDraw superscripts and subscripts and look bad (they go up and down (I think it's because they don't stick to the letter)), I think it's a bug (in case it was and you correct them, after the correction also check the characters written close as I did in the third line (since writing close more real Unicode characters is much easier to use {} with '_, ^'))

    0.png

    2 - If I put TEXDraw in a project and I enable TMP, then to bring TEXDraw to another project I just need to copy the "TEXDraw" folder and put it in the "Plugin" folder of the other project? Or do I have to do the import process for each project?
    (for now I have always done in the first method and have never encountered any problems, but I ask)

    3 - The last one is just an opinion, the "Scroll Area" element of the TEXDraw UI (if I understand correctly and it works for scrolling text), I would put it in an arrow as for "Padding", because it doesn't seem like a main function (but a function to be used manually as for padding)
     
  9. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Yeah, to make it look right, I have to write some special code to handle it. I will try to implement it soon.

    It will work, but you still have to tick the "Enable TextMeshPro Integration", this is because one thing left to do is set TEXDRAW_TMP (and TEXDRAW_TMP_DYNAMIC) to script compilation directives in player settings (this is saved in project-wide configuration). Ticking that menu will set these script directives and enable TEXDraw-TMP rendering code.

    Anyway because there are existing TMP files, the switch should be relatively quick to load.

    I actually considering simply hiding it away from Inspector because its intended usage is only be used through script API (i.e. TEXScroll use this, but that's only it).
     
    Last edited: Jan 7, 2022
    Francesco-FL likes this.
  10. Acegikmo

    Acegikmo

    Joined:
    Jun 23, 2011
    Posts:
    1,294
    got it, thanks a ton for the fix and quick response <3
     
    WillNode likes this.
  11. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Fixed in the latest commit from now. I will update a new version shortly.
     
    Francesco-FL likes this.
  12. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Is there anyone who lives on RTL world? I like to implement RTL here but I need actual user so I can gather feedback.
     
  13. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Multi atlas for TMP dynamic mode to fix this is now supported. A new version has been submitted to Asset Store (wait for a few days for it to appear).
     
  14. floriankorsakissok

    floriankorsakissok

    Joined:
    Jul 19, 2017
    Posts:
    29
    Is there any chance TEXDraw will get support for the UI Toolkit (UITK) in the future? While UITK is not fully released yet, it will soon become largely superior to UGUI and thus the preferred way to create UI in Unity.

    There is no way to draw formulae in UITK though, so adding support for UITK in TEXDraw would fill that need in the new framework.

    I have been using TEXDraw for a while now (in UGUI of course), and I must thank you for an awesome asset!
     
  15. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I didn't think about that before. Added to my backlog. Thanks.
     
  16. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Hi, @WillNode

    Are there any instructions on how to set up Sprite Fonts? I couldn't find this information on the docs (https://willnode.gitlab.io/texdraw/) and what I've found on the Forum didn't help me.

    I actually managed to add some images to the Properties (after a lot of struggle with files with blank spaces between words, an error that was randomly happening during TEXDraw Rebuild Font Data, problems with Symbol Definition syntax etc), but the sprites don't render on the Scene/Game.

    Is there something that I might be missing?

    upload_2022-2-1_15-55-39.png
     
    Last edited: Feb 1, 2022
  17. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    Hey,
    @WillNode.

    I found out what I was missing. I had to add the name of the image to TEXDrawConfiguration Global Symbol Fonts list manually.

    But now I found out another issue, which is more complicated to me. I thought that the Sprites would get all the color information from the .png by default and only tint it, but it doesn't do that. Is there a way for me to have that?

    upload_2022-2-11_20-43-39.png
     
  18. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    From the screenshot I assume you're activating TMP integration right? There could be misconfiguration where I forget to put different shader specific to sprites. I will send the fix update soon to you.

    (btw sorry i forgot to reply your previous question sooner)
     
  19. Fira-Soft

    Fira-Soft

    Joined:
    Sep 9, 2014
    Posts:
    26
    It's not activated, actually. I just tried activating TMP integration on a cleaner test project and it didn't work (testing on TEXDraw-Input scene). I actually found out that, when the integration is active, TEXDraw UI that begins with sprites won't render properly.

    upload_2022-2-14_10-49-57.png
     
  20. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I got a couple of notifications from people requesting access to old documentation links. I don't know where it's come from. I feel I have updated them all. Someone maybe knows where is it?
     
  21. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I have sent you patch updates by email. Will also release this weekend.
     
    Fira-Soft likes this.
  22. AC_GameDev

    AC_GameDev

    Joined:
    Sep 27, 2018
    Posts:
    6
    I'm having an issue with integrals. If I test my code "\int_{2}^{3} \frac{3}{x^2 +1}dx" online here > https://atomurl.net/math/ the formula looks correct but in unity it ends up looking like this. upload_2022-2-21_11-52-39.png

    in the documentation section for large operators I'm seeing an example using and integral but the only code is in the symbols section with \int. Any advice on how to fixt this formatting issue?
     

    Attached Files:

  23. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    (weird... I can't quote right now)

    @AC_GameDev you need to surround it with $$.....$$ or \[...\] so it enters math mode and gives you the correct math syntax.

    upload_2022-2-22_6-31-25.png
     
  24. AC_GameDev

    AC_GameDev

    Joined:
    Sep 27, 2018
    Posts:
    6
    So I had hoped that there was something I was missing. I have tried putting things into math blocks and I am still getting some issues that I'm not sure how to deal with. Things like integral bounds are showing up in weird places like this.
    upload_2022-2-23_11-48-40.png

    $$ \int_1^\infty\frac{1}{x^2} dx $$
     
  25. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Sorry for the late reply. I get the correct result. Have you made sure to have the latest version? (6.0.1)
     
  26. AC_GameDev

    AC_GameDev

    Joined:
    Sep 27, 2018
    Posts:
    6
    I could have sworn I was up to date but it turns out I wasn't. Thanks for the response.
     
    WillNode likes this.
  27. eduardon83

    eduardon83

    Joined:
    Feb 5, 2021
    Posts:
    1
    Hi There @WillNode
    We're trying to use TexDraw, we're running TMP at 3.0.6 and your latest version.
    We keep getting this error

    https://imgur.com/a/3etXaxC

    Anything we can do on our end to fix it?
     
  28. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Weirdly I can only see one from three of your images.

    It's a harmless error. It's mean it's trying to enable the compilation flags for all platforms. But all installation has different build platform availability but I can't get rid of that error (I should tell these in console logs too)
     
  29. brettvandesande

    brettvandesande

    Joined:
    Oct 6, 2020
    Posts:
    7
    I need to add some plain text inside a math expression. In LaTeX, I would use \mbox{} or the AMS package function \text{} to do this. These seem to be missing in TEXDraw. Is there a work-around?
     
  30. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Just an update, today I released a new version v6.0.3 and it's already live but I forgot to update the version metadata. The updated version notes are in the docs. I will update the metadata today.
     
  31. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    How to change language font(using custom font) in runtime in TEXDraw?
    Thank you so much for your attention and help.
     
  32. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I assume you already know how to import font properly.

    You can add a prefix command with the font name. e.g. `\opens` will activate Open Sans for the rest of the text.
     
  33. TechnicalArtist

    TechnicalArtist

    Joined:
    Jul 9, 2012
    Posts:
    736
    Thanks for your support
     
    WillNode likes this.
  34. Muhammad_Fathulloh

    Muhammad_Fathulloh

    Joined:
    Feb 13, 2021
    Posts:
    11
    upload_2022-5-8_9-58-27.png
    I want to display fraction text out of canvas. Because Square GameObjects are not in the Canvas. They are in the SpriteRender.
    Is there any way to solve this issue in TexDraw asset?
     
    Last edited: May 8, 2022
  35. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    You can enable TextMeshPro integration so it will be crisp at all resolution.
     
  36. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    58
    @WillNode
    8^2+6,
    How to get result is equal to 70.
     
  37. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    You... can simply type it?
    8^2+6=70
     
  38. TheFlyHawk

    TheFlyHawk

    Joined:
    Mar 23, 2016
    Posts:
    58
  39. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    We don't do that here.

    I have a C# library that does this... It's pretty old but I'm sure it still works in Unity.

    Check here: https://willnode.github.io/ComCalc/
     
  40. Muhammad_Fathulloh

    Muhammad_Fathulloh

    Joined:
    Feb 13, 2021
    Posts:
    11
    upload_2022-5-13_18-58-33.png
    Hello. I want to change the font of what I wrote in the TexDraw3D component. How do I change the font in a component? I can't find a place to select the font.
     
  41. ForegoneSorrow

    ForegoneSorrow

    Joined:
    Feb 8, 2022
    Posts:
    2
    Hello! I just purchased a license for TexDraw. It looks great.

    What I need to know is how I can do string interpolation with TexDraw to put ints, strings, floats, etc from my scripts to display inside the rendered latex. I'm creating a teaching tool for teaching the planning/reinforcement learning side of AI. I want to be able to show the equations and nicely formatted pseudocode as the algorithm visualisation runs. In other words, if I was just using regular strings I'd do:
    Code (CSharp):
    1. $"V(s{variable})"
    .
    Essentially, I want to be able to produce something similar to what is in the image attached, where the squares are replaced with values from the code in game. ExampleForHelp.png
     
  42. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Hi, you can only set the font by using the command name. Please read here. If you want to set that custom font as the default font for all in the project, you can configure that in TEXPreference.
     
  43. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I might be misunderstood your question but... Can't you simply set the string to TEXDraw?

    Code (CSharp):
    1. var number = 5;
    2. var texdraw = GetComponent<TEXDraw>();
    3. texdraw.text = @"\sqrt{" + number + @"}";
    Another way to do it is using a string literal. I'm not sure if that's already available with the recent version of Unity.
     
    ForegoneSorrow likes this.
  44. ForegoneSorrow

    ForegoneSorrow

    Joined:
    Feb 8, 2022
    Posts:
    2
    Thanks for the quick reply! Yeah I've been using string literals so far, I just wondered if there was a quicker way—it was also super late last night.

    Thanks again, Will!
     
    WillNode likes this.
  45. SuperTung

    SuperTung

    Joined:
    Apr 27, 2017
    Posts:
    9
    @WillNode, Hello i want to confirm before purchase, does the plugin support vietnamese character(utf-8 font) ?
    Does it support add new font and how to do it, and thank you for amazing plugin ;)
     
  46. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    It supports all characters as long as the font support it.

    So to use Vietnamese characters, you need to load a font that has those characters and make it the default typeface. I explained the process here.
     
  47. SuperTung

    SuperTung

    Joined:
    Apr 27, 2017
    Posts:
    9
    @WillNode , Hi there, i purchased the asset, can i ask how to control the font size like 24 25 26, now i just see padding options, overflow options ?
     
  48. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Hmm, is the size options just below the text input don't visible to you?

    Alternatively, you can set the size via latex commands for precise controls.
     
  49. SuperTung

    SuperTung

    Joined:
    Apr 27, 2017
    Posts:
    9
    i'm sorry i missunderstood, my issue is: I have multiple TEXdraw object, and when I use best fit option, it will have different size cause it have different content, i want to get the size of smallest best fit object of them to set the size for all of them again after best fit is seted, can i do that ?
     
  50. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    That's something you can't do without diving into the internal TEXDraw orchestrator and doing the scripting yourself.

    There's an undocumented variable that you're looking for:
    TEXDraw.orchestrator.fitScaling
    the value is a number between 0 and 1 about how much scaling that is already been affected by BestFit for each individual TEXDraw object.

    So.. If I were you I would script this to only one object and write something like...

    Code (CSharp):
    1. IEnumerator Start() {
    2.   yield return null;
    3.   var smallestSize = 100;
    4.   for (var tex in FindObjectsOfType<TEXDraw>()) {
    5.     smallestSize = Math.Min(smallestSize , tex.orchestrator.fitScaling * tex.size);
    6. }
    7. for (var tex in FindObjectsOfType<TEXDraw>()) {
    8.    tex.size = smallestSize;
    9. }
    10. }
    (I just write it on top of my head adjust accordingly)