After working a bit with maya/blender, I noticed that the interpreter is very useful for programatically editing the scene.
Yes, unity gives us lots of flexibility for scripting, but its a bit overkill in some cases (for example, batch-placing objects in the scene at edit time).
I thought that unity could use an interpreter, so I made one!
To use, just import the attached unity package and go to Window->Python Interpreter.
If you want to see an example, have a look at the screenshot where I create a cube and change a few properties.
A few notes :
1 - This is pure python (I used IronPython), and not unity’s variant of python. However, you can access all of the unity classes with the same name conventions as the C# API.
2 - History colors : Green = commands, Blue = return values, Black = Python output, Red = Errors.
3 - The editor is really basic. I just did the simplest thing that is functional.
As for the future, the main problem is of course the editor. I would like to have
a - Autocompletion
b - command history via up/down arrows
c - ability to copy/paste text from the history view
d - ability to load/save scripts, and perhaps open additional tabs.
I feel that the EditorWindow API is lacking in its flexibility, for example the Input.XXX set of functions isnt available. How would I solve b?
Anyway, I will release it soon to the Asset Store (for free), and will be really happy if I’ll be able to add some of the features to the editor.
If anyone wants to contribute, either by improving the editor or by giving me tips on how to do it within a Unity EditorWindow, I’ll be very happy (code contributions will be credited, of course!).
As always, I’m open to comments, suggestions and bug reports for this script.
Have fun!