Search Unity

TEXDraw - Create Math Expressions inside Unity!

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

  1. brettvandesande

    brettvandesande

    Joined:
    Oct 6, 2020
    Posts:
    7
    I am using the "align" environment to show several rows of equations. How do I best adjust the space between rows? Right now, the rows are too close together.
     
  2. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Hmm... Looks like I missed that part, there's no way to adjust it currently. The rows have 0 paddings vertically.
     
  3. brettvandesande

    brettvandesande

    Joined:
    Oct 6, 2020
    Posts:
    7
    In LaTeX, you would normally use something like
    \\[12px]
    to adjust the spacing for an individual row. To do it more globally would be something like `
    \renewcommand*{\arraystretch}{1.5}
    .
     
  4. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Actually, I have implemented \\[12px] recently, also added vertical margin in "align". It's still on GitLab repo. I plan to update a new version this weekend.
     
  5. brettvandesande

    brettvandesande

    Joined:
    Oct 6, 2020
    Posts:
    7
    I hope you can do this update sometime soon.
     
  6. Tom_Olsen

    Tom_Olsen

    Joined:
    Oct 11, 2020
    Posts:
    10
    Hey. Why is there no way to change the pixelPerUnit property via script?
    I added it myself in the TEXDraw3D.cs script. Is this in some way dangerous, or why is this missing? Otherwise it would be nice if you could add this in future versions.

    Code (CSharp):
    1.  
    2.     public virtual float size
    3.     {...}
    4.  
    5.     public virtual float pixelsPerUnit
    6.     {
    7.         get
    8.         {
    9.             return m_PixelsPerUnit;
    10.         }
    11.         set
    12.         {
    13.             if (m_PixelsPerUnit != value)
    14.             {
    15.                 m_PixelsPerUnit = Mathf.Max(value, 0f);
    16.                 Redraw();
    17.             }
    18.         }
    19.     }
    20.  
    21.     public virtual Color color
    22.     {...}
    23.  
     
  7. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Wow, I have forgotten.
    Thanks for noticing me!
     
  8. jahongirmardonov2003

    jahongirmardonov2003

    Joined:
    Feb 8, 2022
    Posts:
    2
    Hi Screenshot_1.png Screenshot_2.png . I want to add a new font to TextDraw. In the documentation, there is information about adding a new font, but I did not understand the last part. Add font name to part of image? i did that but it doesn't work for me
     
  9. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I might need to add more explanation.

    You need to go from Menu Bar -> Tools -> TEXDraw -> Show Preference, then go to the Configuration tab.
    The difference with directly opening the config file is that there's a "Refresh" button that will update all TEXDraw objects in the scene, otherwise you have to close and reopen the scene file to see the effect.

    Also, make sure to type in the exact font name (without extension) e.g.
    MyFont
    (case-sensitive), the font name must have no space.
     
    jahongirmardonov2003 likes this.
  10. jahongirmardonov2003

    jahongirmardonov2003

    Joined:
    Feb 8, 2022
    Posts:
    2
    Thank you very much. I was able to add a new font. I have another question. Does TextDrow have Auto Size? If so, how can I use it?
     
  11. Muhammad_Fathulloh

    Muhammad_Fathulloh

    Joined:
    Feb 13, 2021
    Posts:
    11
    Hi there. I wanted to use TEXDraw to output long and short text. Does TEXDraw have autosize? If so, how can I use it?
     
  12. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    You can add a Content Size Fitter or put it inside a Horizontal/Vertical Layout Group.
     
  13. MediaMonks

    MediaMonks

    Joined:
    May 29, 2013
    Posts:
    7
    Hello,

    I'm having some problems using the tmp/sdf integration. It looks like some triangle halves of some quads are not rendering properly (seems to change randomly as I change the text). Does this problem look familiar to anyone? Does anyone have a solution?

    It only happens using the tmp integration. Using 2021.3.0f1 LTS with URP.

    upload_2022-8-1_14-15-30.png upload_2022-8-1_14-15-40.png
     
  14. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I'm using Unity 2019.4 LTS mac and Using URP. I have no issues. Will try your unity version. Meanwhile, can you tell us The OS, or maybe you can send a minimalistic project that reproduces the issue?
     
  15. MediaMonks

    MediaMonks

    Joined:
    May 29, 2013
    Posts:
    7
    I'm Using 2021.3.0f1 on a Windows machine with the target platform set to standalone (android as target platform has the same issue)
    I created an empty URP project, imported TMP essentials, imported TEXTDraw, enabled TMP integration, copied an example scene, put the projection of the camera to Perspective and the canvas to World Space. That combination makes the text look broken.
     
  16. ELC2909

    ELC2909

    Joined:
    Jun 17, 2016
    Posts:
    8
    Last edited: Aug 19, 2022
  17. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    This has been further discussed in private conversation and fixed in an upcoming version. Thanks.

    No, and I don't think it's worth implementing. TEXDraw code is really different than LaTeX itself. For graphics, I recommend converting it to an SVG file and using a package (in the asset store) that can handle SVG.
     
  18. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Meanwhile, I just created a video tutorial for TEXDraw, hope you'll like it :)

     
    HideOnStones likes this.
  19. ELC2909

    ELC2909

    Joined:
    Jun 17, 2016
    Posts:
    8
    Thanks for your response. But what command does TEXDraw use to create a text box? I've tried /fbox on the demo but it doesn't work.
    One more thing, will TEXDraw render a text that use HTML tag like <b> </b>, <u>, and <i>?
     
  20. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    I didn't implement that yet, the closest one/current workaround is using a tabular environment with one cell.

    It was supported, but support was dropped from 5.x since it has poor support. I found some gist that may be useful for writing custom HTML to LaTeX converter.
     
  21. victorolo

    victorolo

    Joined:
    Sep 8, 2022
    Posts:
    1
    Good morning!

    I have been watching the code of the caret, and I see that this has not been updated since 2020. I was expecting that the movement of the caret was a little bit more like a scientific calculator. Furthermore, I was wondering if you have plans of updating it in the near future.

    Thanks for your time!
     
  22. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    The caret in TEXInput? I do have plans to revamp it further. But currently, I have no specific date when I can do that.
     
    victorolo likes this.
  23. Muhammad_Fathulloh

    Muhammad_Fathulloh

    Joined:
    Feb 13, 2021
    Posts:
    11
    Hi.
    I have a question about writing a mathematical formula.
    upload_2022-11-12_9-21-47.png
    How can I write a dash above the X?
     
  24. Muhammad_Fathulloh

    Muhammad_Fathulloh

    Joined:
    Feb 13, 2021
    Posts:
    11
    Hi everyone.
    I have question. Does textdraw asset support iOS?
    upload_2022-11-12_15-4-40.png
    This is on android mobile phone.
    upload_2022-11-12_15-10-32.png
    And this is on iOS platform on unity.
     
  25. Muhammad_Fathulloh

    Muhammad_Fathulloh

    Joined:
    Feb 13, 2021
    Posts:
    11
    Hello.
    I have problem with TexDraw.
    When I run my project on iOS platform, TexDraw is not visible.
    Does TexDraw support the iOS platform?
    upload_2022-11-15_9-52-55.png
    This is on Android platform.
    upload_2022-11-15_9-54-47.png
    This picture from iOS platform

    Thanks for the help.
     
  26. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    *pokes*
     
  27. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
    can you paste a link to the full error dump and version of unity and version of texdraw etc
     
    WillNode likes this.
  28. ina

    ina

    Joined:
    Nov 15, 2010
    Posts:
    1,085
  29. lxciian

    lxciian

    Joined:
    Dec 16, 2020
    Posts:
    2
    Hey guys! Can we receive some inputs from the user in runtime with that plugin?
     
  30. FarJudy

    FarJudy

    Joined:
    May 8, 2019
    Posts:
    3
    First of all: thank you Willnode for this amazing tool, without it I would not be able to fully support math notation in my educational games. I'm running into an issue however with Unity LTS 2021.3.24f1 and TexDraw 6.0.5 where custom TextMeshPro materials are not working. TexDraw refuses to use anything other than the Assets/Plugins/TEXDraw/Resources/TEX-Default.mat for any TexDrawUI components. Any suggestions? Is this a bug?
    upload_2023-5-18_11-2-40.png

    The blue question text at the top should not have this pink glow outline that I've applied to the default material, its assigned material has no outline or styling.
    upload_2023-5-18_11-4-52.png
     
  31. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    (following from email) TEXInput is the way to do it. Upcoming version will handle this much better.

    It is a bug. Fix will come in upcoming version.

    Today I plan to submit a new version to asset store.
     
    FarJudy likes this.
  32. FarJudy

    FarJudy

    Joined:
    May 8, 2019
    Posts:
    3
    I'm getting a lot of errors when trying to import version 6.1.0 even if I delete the TEXDraw folder first...
    upload_2023-5-24_12-39-17.png

    EDIT: Solved the ReflectionUtility error by removing any instances of ";TEXDRAW_TMP;TEXDRAW_TMP_DYNAMIC" under "scriptingDefinieSymbols" in ProjectSettings/ProjectSettings.assets

    May be an issue for other people attempting to do an update

    ADDITIONAL EDIT: Enabling TMPro integration after doing the above leads to the same error:
    "Assets\Plugins\TEXDraw\Core\TexImporterSDF.cs(11,14): error CS0246: The type or namespace name 'ReflectionUtility' could not be found (are you missing a using directive or an assembly reference?)"

    I also receive all of the same errors about a folder with a period as the first char, like in the screenshot above, if I try to re-import TEXDraw. I'm assuming you're developing on Linux?

    Final EDIT:
    "could not create directory for asset" errors maybe related to this? ... https://issuetracker.unity3d.com/is...-packages-and-one-of-them-is-already-imported
     
    Last edited: May 24, 2023
  33. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    My bad. Didn't check compilation errors before submit.

    To solve this issue while keeping TMPro integration intact, open the script file (TexImporterSDF.cs), at line 11 change from

    Code (CSharp):
    1. using static ReflectionUtility;
    to

    Code (CSharp):
    1. using static TexDrawLib.ReflectionUtility;
    This fix has been patched in GitLab repo and subsequent update will be published. Thanks for reporting.
     
    FarJudy likes this.
  34. Mitsu0711

    Mitsu0711

    Joined:
    May 4, 2022
    Posts:
    2
    I wanted to express my sincere gratitude for the amazing asset you have created. It has been instrumental in my projects, and I appreciate the hard work and dedication you have put into it.
    I am interested in modifying the size settings for superscripts and subscripts from the preferences. Upon reviewing the PDF file of the historical version, I noticed that there was a "script factor" within the scale factors of the preferences, allowing for adjustments in the sizes of superscripts and subscripts. However, in the current version, I couldn't find such an option in the preferences. I was wondering if the ability to adjust the sizes of superscripts and subscripts has been removed, or if I might have overlooked something. It would be immensely helpful if you could provide some clarification on this matter.
    Thank you for taking the time to consider my question. I genuinely appreciate your expertise and your contributions to the TEXDraw asset. I look forward to your response.
     
  35. Mitsu0711

    Mitsu0711

    Joined:
    May 4, 2022
    Posts:
    2
    I am writing to inform you that I have resolved the question I asked earlier.

    Since the issue has been resolved before receiving your response, there is no need for a reply.
     
    WillNode likes this.
  36. JackyLo520

    JackyLo520

    Joined:
    Feb 15, 2021
    Posts:
    2
    upload_2023-6-13_22-42-43.png

    I am a new user to TEXDraw, from the above picture, I am not sure why the spaces are automatically added there, any causes and solutions?
     
  37. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Justify is enabled by default for all text. If you want to disable it across the project then go to the preferences file and then untick "Justify".

    \flushleft
    also can be used if you want it just for specific components.
     
  38. JackyLo520

    JackyLo520

    Joined:
    Feb 15, 2021
    Posts:
    2
    It works perfectly now and solved my problem. Thank you so much!
     
    WillNode likes this.
  39. DaniTM_Inno

    DaniTM_Inno

    Joined:
    Jun 15, 2023
    Posts:
    2
    Hello! We are trying to make an animation to change the font color of a TEXDrawUI component, but the color doesn't update. Is there any way to fix it?



    At the video there are the same example animation in the TEXDraw component and a TMP component to see the difference. You can also see how the color of the TEXDraw font changes in the editor but not in the scene.

    Thank you!
     
  40. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
  41. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Does this error message matter? This is using Unity 2022.3.2f1, on a Mac Silicon M2:

    Screen Shot 2023-06-20 at 05.32.49.png

    It seems I can draw stuff ok, so maybe it doesn't matter??? But I suspect I will find some specific thing not working later on?

    (PS Beautiful rendered latex text :) Awesome :) )
     
  42. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    How to control vertical alignment? I'm testing a simple animation using:

    Code (csharp):
    1.  
    2. using System;
    3. using UnityEngine;
    4.  
    5. namespace TryTexDraw {
    6. public class Controller : MonoBehaviour {
    7. [SerializeField] string[] fullLatexExpressions = new string[] {
    8. "y",
    9. "y =",
    10. "y = x",
    11. "y = x^2",
    12. "y = x^2 + \\sum_{i=1}^j",
    13. };
    14. [SerializeField][Range(0.01f, 5)] float animRevealTime = 1f;
    15. [SerializeField] bool reset = false;
    16.  
    17. TEXDraw _texDraw;
    18.  
    19. float _revealStartTime = 0;
    20.  
    21. void OnEnable() {
    22. _texDraw = GetComponentInChildren<TEXDraw>();
    23. Debug.Log($"texDraw {_texDraw}");
    24. }
    25.  
    26. void Update()
    27. {
    28. if (reset) {
    29. _revealStartTime = Time.time;
    30. reset = false;
    31. }
    32. var itemToReveal = Math.Min(fullLatexExpressions.Length - 1, (int)((Time.time - _revealStartTime) / animRevealTime) - 1);
    33. _texDraw.text = itemToReveal == -1 ? "" : fullLatexExpressions[itemToReveal];
    34. }
    35. }
    36. }
    37.  
    However, you can see that if the text field is top aligned, then when the ^2 appears, then the text so far shifts down. This is fixable by using bottom alignment. However, with bottom alignment, when the \\sum appears, the text shifts up. Middle alignment works for \\sum, but not for ^2. How to handle this, so I get beautifully animated appearing text?

    Edit 1: Thinking about this, one solution might be if I could render the entire text each time, but simply change the alpha, or the color, of some of the text?

    Edit 2: Oh... thats the solution :)
     
  43. DaniTM_Inno

    DaniTM_Inno

    Joined:
    Jun 15, 2023
    Posts:
    2
    WillNode and hughperkins like this.
  44. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    Interesting. TEXDraw-UIE is an experimental support for UI Elements. I guess that you've disabled UI Elements, which is totally fine. You can delete all files related to UIE in 'Scripts' folder if you want to.

    That is the correct way!
     
  45. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Interesting. Thanks!

    Cool. Don't suppose... is there any way of setting the text color as alpha/transparent, rather than black? Using black is workable for many situations, but alpha will increase flexibility, reduce cognitive load, increase the number of cases where it works perfectly.
     
  46. WillNode

    WillNode

    Joined:
    Nov 28, 2013
    Posts:
    423
    It's working...

    upload_2023-6-21_8-15-14.png

    Also it does work with Color property set in the object.
     
  47. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    So, that's the background in alpha, but how to draw text in alpha? I can draw in black, but I dont see how to draw in alpha? Example: I have
    Code (csharp):
    1.  
    2. \frac{\partial \mathbf{v}}{\partial t} = - \color{black}(\mathbf{v} \cdot \nabla)\mathbf{v}
    The output is:

    Screen Shot 2023-06-20 at 21.27.47.png

    Whereas I want the output to look like:

    Screen Shot 2023-06-20 at 21.28.33.png

    Thoughts?
     
  48. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    oh, like this, neat :)
    Code (csharp):
    1.  
    2. \frac{\partial \mathbf{v}}{\partial t} = - \color{#ffffff00}(\mathbf{v} \cdot \nabla)\mathbf{v}
     
  49. hughperkins

    hughperkins

    Joined:
    Dec 3, 2022
    Posts:
    191
    Awesome :)
     
    WillNode likes this.
  50. devPatrick

    devPatrick

    Joined:
    Sep 28, 2018
    Posts:
    22
    Is it possible to achieve a text underlay? It appears the TextMeshPro shaders are unsupported. With most of the TMP shaders, the glyphs appear as just colored squares. The only TMP shader that kind of works is the distance field SSD (the text appears fine with normal settings, but the underlay is screwed).

    Edit: I'm using version 6.1.1