Does unity C# support an exec method?


Put very simply, I want to achieve something along the lines of:

string runcode = "interaction_player_door myscript = prcHit.transform.GetComponent<interaction_player_door>();";



UnityScript does have the eval(runcode) function which is both inefficient and error-prone, though it works. As far as I know, there’s no C# equivalent, though I want to mention Reflection which might - in some case only - achieve a similar result.

Even though I generally use C#, I find handy to keep a UnityScript console around to try crazy unplanned stuff at runtime - I still avoid it for production code.