- Home /
Eval or Can I call JScript from an Editor C# Script?
I'm in need of an 'eval' function as in Javascript, but C# has none (and I don't care for the C# implementations). It needs to run in an Editor script, which is C#.
So I figured I'd make a little Javascript:
function evaluate(s)
{
eval(s);
}
But I'm getting the old 'does not exist in the current context' error. I tried moving the eval jscript to the Plugins folder, no luck.
Any other way to do this?
Answer by Duckblaster · Oct 02, 2010 at 10:56 PM
would Mono.CSharp.Evaluator.Evaluate(System.String) work? http://www.go-mono.com/docs/monodoc.ashx?link=M%3aMono.CSharp.Evaluator.Evaluate(System.String)
That sounds pretty good, but when I try it, I get the following error when I run it: TargetInvocationException: Exception has been thrown by the target of an invocation. System.Reflection.$$anonymous$$ono$$anonymous$$ethod.Invoke (System.Object obj, BindingFlags invokeAttr, System.Reflection.Binder binder, System.Object[] parameters, System.Globalization.CultureInfo culture) [0x00000] System.Reflection.$$anonymous$$ethodBase.Invoke (System.Object obj, System.Object[] parameters) [0x00000] UnityEditor.HostView.Invoke (System.String methodName) UnityEditor.HostView.OnGUI () at System.Reflection.$$anonymous$$ono$$anonymous$$ethod.Invoke (System.Object
I'm gonna say that's the answer I needed to get me in the right direction, even if I haven't gotten in to work properly yet.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Distribute terrain in zones 3 Answers
Is there eval() for C#? 2 Answers