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!
Since 2016, you can use TEXDraw (Paid asset) to render mathematical expressions in unity.
You can do LaTeX math with a web api and download it as a texture. An example:
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.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With