Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Display mathematical equation in unity3D

I want do display mathematical equation in unity using it's GUI system. Is there a way? I am using c# language for programming in Unity. It would be useful for me if I could also display mathematical symobls using c# code. Thanks!

like image 827
user3765498 Avatar asked Oct 17 '25 03:10

user3765498


2 Answers

Since 2016, you can use TEXDraw (Paid asset) to render mathematical expressions in unity.

like image 148
Chemical Programmer Avatar answered Oct 18 '25 21:10

Chemical Programmer


You can do LaTeX math with a web api and download it as a texture. An example:

enter image description here

How to use in Unity3d:

using UnityEngine;
using System.Collections;

public class Tester : MonoBehaviour {

    [SerializeField] string formula=@"\displaystyle\int_{-\infty}^{\infty}e^{-x^{2}}\;dx=\sqrt{\pi}";
    Texture texture=null;

    IEnumerator Start() {
        WWW www=new WWW("http://chart.apis.google.com/chart?cht=tx&chl="+formula);
        yield return www;
        texture=www.texture;
    }

    void OnGUI() {
        if(texture != null)
            GUI.DrawTexture(new Rect(0,0,texture.width,texture.height), texture);
    }
}

There are many implementations,used here is the Google Charts API. Unfortunatly it will be retired in a year or so.

If you don't want google's, an alternative is a custom hosted tex2im.

like image 31
Krzysztof Bociurko Avatar answered Oct 18 '25 21:10

Krzysztof Bociurko



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!