Using Text file with .JS code written on it in webplayer?

Hi Unity Coders ?:slight_smile:

I would like to have a text input field next to a compiled webplayer game, where the player can write some lines of a function, and then the player can start the webplayer and it will import his code as something the game can read.

just for easy code for example:

function equation(){
   var form = Mathf.Min(Mathf.Abs(x-Mathf.Floor(x+0.5)),Mathf.Abs(z-Mathf.Floor(z+0.5)));
   return form;

It the task possible using an addon/dll/unitylibrary?

You don’t need any add-ons; you can use the eval() function to run strings as code. Note that you must turn off #pragma strict for eval() to work. So it doesn’t work on platforms that enforce #pragma strict, like iOS.