- Home /
Question by
Brenden-Frank · Aug 22, 2012 at 04:11 AM ·
c#stringrealtimeexecute
Does unity C# support an exec method?
Hey!
Put very simply, I want to achieve something along the lines of:
string runcode = "interaction_player_door myscript = prcHit.transform.GetComponent<interaction_player_door>();";
exec(runcode);
Possible?
Comment
Best Answer
Answer by by0log1c · Aug 22, 2012 at 04:28 AM
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.
Your answer
Follow this Question
Related Questions
Multiple Cars not working 1 Answer
Using strings still bad in 4.6 ? 1 Answer
Executing a string as a code snippet. 2 Answers
Distribute terrain in zones 3 Answers