interpret unityscript at runtime?

is it possible for unity to interpret a unityscript at runtime, i. e. could i enter unityscript commands in a gui and execute that at runtime?

Actually, this can be done when using UnityScript since it is based off of the Microsoft JScript language in the .NET Framework. It is, however, NOT recommended for performance and security reasons. If you still want to do this for something like an in-game debugging console, you can use the eval() function. For further reference, please see the .NET documentation on JScript's implementation of the eval() function here:

I'd rather add this as a comment to Justin's answer because it's correct, but I can't do code formatting that way, and I wanted to add a little example:

import UnityEngine.GUILayout;
private var exeText = "";
private var run = false;

function OnGUI () {
    exeText = TextField(exeText, Width(600));
    if (Button("Execute", Width(60))) {
        run = true;
    if (run) {

Put some GUI code in the text field, click execute, and see what happens, like this maybe:

for (i = 1; i <= 10; i++) Label(i.ToString());

Of course, it's trivially easy to crash Unity that way by entering junk instead of valid code.

actually there are 3 ways to do this. 1 using Eval as Erric5h5 said. (i did not test it) 2 mono has a class for compiling C# code at runtime. i think lucas meijer made a ingame console debugger with it. 3 when unity releases 3.0 and updates to newer version of mono (they will upgrade to 2.6 just like iphone but even 2.2 is enough) you can use DLR and ironpython or ironRuby or your own scripting language to run scripts at runtime.

it's the best way to make patches easily

You can try this: LEDA Runtime Scripting Language | Tools | Unity Asset Store

Nope. The 'script' in unity is actually compiled to an intermediate language when you build your app, and then compiled to machine code at runtime, using the JIT compiler.

EDIT: Oops. This is wrong. Sorry guys.