- Home /
can I use eval to test the syntax on code a user enters during runtime?
I have a project that teaches unity javascript. I want a user to type in unity javascript code but then I want to catch syntax errors and show them back to the user.
I can do this type of syntax checking in a html/javascript page by using a combo of try catch and eval(). Is this the only way to do something like this in Unity?
var usercode="x=2;y=x+x;"
try {
eval(usercode);
} catch(err) {
alert("error caught");
}
Comment
Your answer
Follow this Question
Related Questions
Try/ Catch does not work with Network.InitializeServer 2 Answers
Try and catch very slow 1 Answer
Can't Catch IndexOutOfRangeException 1 Answer
Try Catch not executing. 3 Answers
Why is my Try and Catch not working? 1 Answer