Modifying running scripts?

Is it possible to modify running scripts - or to execute JS/C# script from string on an object?
I know C# is compiled, but JS?

Thanks.

UnityScript is also compiled and all 3 languages result in the same thing: a compiled .NET / Mono assembly.

However UnityScript has the [“eval” function][1] like JavaScript, but it’s slow and limited and as far as i know is not supported on all platforms. Apple for example doesn’t allow any dynamic code in iPad / iPhone apps.

You can’t modify any compiled scripts since they only exist in their compiled form in a built game. The usage of eval / CSharpCodeProvider / … is actually very dangerous since the user could totally break the game or change things he shouldn’t.

Depending on your actual usage there might be better solutions out there like an actual scripting language like

[2]. Since such a scripting language runs in a VM you have much more control over what is allowed / possible.


  [1]: http://answers.unity3d.com/questions/7885/interpret-unityscript-at-runtime.html
  [2]: http://lua-users.org/lists/lua-l/2013-02/msg00000.html