Hi to all, i would like to know how to convert a string that contain a Mathf functions (ex : Mathf.Sin(Mathf.Pow(1, 2.0) + Mathf.Pow(2, 2.0))) to Javascript language, without incurring in this error : "FormatException : Unknown char: M" P. S = i have tried with : "float.Parse()". Thanks.
Are you trying to convert a formula string into a float? so "Mathf.Sin(Mathf.Pow(1, 2.0) + Mathf.Pow(2, 2.0)))" would result in say 8 or whatever the result is?
How does it work??? I searched for the eval function and found a massive wall of forum posts / QA posts that are saying its not possible because C# is a complied language and not a interpreter one. If it works how?
Yes i tried it, but Unity give me this error : UnityScript.Scripting.IEvalutationDomainProvider' interface member implementation must be public or explicit My intention is that write more formulas like that in my first comment, and convert these to float (ex : graph.tk), but without convert string into JS i can't make this.
Ok guys, i have resolved eval() error, with delete all scripts contain "#pragma strict" Thanks for help
It's a Unityscript feature, not C#. It works by recompiling the code on the fly, so there's a noticeable pause when code is compiled the first time. (And yes, it doesn't work with #pragma strict, which also means it doesn't work on iOS.) --Eric