Search Unity

  1. Megacity Metro Demo now available. Download now.
    Dismiss Notice
  2. Unity support for visionOS is now available. Learn more in our blog post.
    Dismiss Notice

new problem!

Discussion in 'Scripting' started by chubbspet, May 31, 2011.

  1. chubbspet

    chubbspet

    Joined:
    Feb 18, 2010
    Posts:
    1,220
    hi there guys

    I am currently making an app in unity where the user can type a math formula into a text box and it will imply certain behaviour on objects. I'm using the javascript eval to parse the user math expression. My question is this, how can I include a variable into this formula. For example if the code is like this:

    Code (csharp):
    1. var x = 2;
    2. var userExpression = "x*x+x";
    3. var y = eval(userExpression);
    Thanks in advance