Lucas Meijer

Game Development Consultancy

17 Mar, 2009

Message Window in Unity


Remember the message window that Director has? Very useful if you just want to quickly try out something. Do it while your game is running or not running, it’s all good.
It’s one of the few Director features that I’ve missed in Unity for a while. When Miguel de Icaza announced an interactive c# program, I was very excited, as this opened the door to a message window in Unity.

I’m not completely done yet, but check out this preview of an in-unity c# “message window”.

(not embedding as the swf has huge dimensions)
http://lucasmeijer.com/files/messagewindow.swf

A few notes:

  • This works at runtime, in your webplayer too. (at a hefty 3mb pricetag)
  • This should work in Unity 2.1 as well.
  • Careful readers will note the usage of the ‘var’ keyword, which is not supported by the version of Mono that Unity embeds. This is because this tool embeds its own c# compiler, and I chose to use a much more recent version of the mono c# compiler than what Unity ships with. Don’t look at this video and think Unity2.5 will ship with an upgraded Mono.
  • Still have lots of stuff to add. Tab completion, Intellisense, shift-return executing multiple lines, being able to drag gameobjects in, and have them be replaced by GameObject.Find(”thename”);
  • Miguel+friends did all the real work, I just put a few pieces together.
  • All in all, it’s great fun to work on some tech purely for fun again.

    I’ll probably release this as an open source package when it doesn’t require tiptoeing around all its infancy problems. Maybe I’ll talk the unity guys into including it in the next version.

    I think this shows again what great move it was for Unity to embed Mono. Mono rocks.

8 Responses to "Message Window in Unity"

1 | Emil Johansen (AngryAnt)

March 17th, 2009 at 2:02 pm

Avatar

*very* interesting. Perhaps the MonoBehaviour definition failed because you didn’t specify the Rect parameter for GUI.Button? ;)

http://unity3d.com/support/documentation/ScriptReference/GUI.Button.html

Does the example work if you do specify it?

2 | David Helgason

March 17th, 2009 at 4:44 pm

Avatar

You, Lucas, are a genius!

d.

3 | Benoit FOULETIER

March 17th, 2009 at 5:11 pm

Avatar

Awesome! I’ve been meaning to do that for months but I could only see ways to do it in Javascript… C# sweetness :) !

One super-cool feature would be to automatically loop on the selection; eg the helper would iterate on the selected GameObjects, giving me “go” as the entry points, so I could just do for example “go.transform.position *= 2;”

About Intellisense, you probably know this guy already if you know the Mono crew, he made a Reflector addin called Reflexil that has embedded Intellisense, with code-folding and all! http://sebastien.lebreton.free.fr/reflexil/

Can’t wait till you release this :) !

4 | lucas

March 17th, 2009 at 7:31 pm

Avatar

Glad people like it. @AngryAnt: no, aras suggested that too, still doesn’t work. @David: I envy your optimisim :) , @Benoit: I don’t think I’d need to use reflexil. Miguel has added autocompletion support to the actual c# parser, (or is in the process to actually).

This could probably use a lot of snippets. I guess my demo didn’t fully showcase all the things you can do:

foreach(var go in Selection.GetObjects()) go.transform.Translate(0,2,0); should work just fine to iterate over the selection. (warning email syntax, maybe the selection api is a bit different, but you catch the drift).

you could also do linq stuff:

from go in allgameobjects where go.name.Length > 3 select go.transform;

etc..

anyway, back to gdc prepping.

5 | Hanford

March 18th, 2009 at 12:40 am

Avatar

Very cool! I would love one for JS (but I don’t expect you to make one).

Are you allowed to show Unity for windows yet?

6 | Jeffrey Carpay

March 18th, 2009 at 1:16 pm

Avatar

This rocks, would love to see this integrated in a future Unity release.

7 | Keli Hlodversson

March 20th, 2009 at 12:01 pm

Avatar

Impressive. Now Unity 2.5 has been released officially, will you provide a unityPackage for download?

@Jeffrey I don’t see how it needs a new Unity release, as this does not require modifying Unity at all.

8 | Gabriel

November 20th, 2009 at 12:12 pm

Avatar

Hey this is great! Where can I get that?

Comment Form

Game Development Consultancy

Hi. I'm Lucas Meijer. consultant on game development projects I work at Unity. You're looking at my portfolio website.

Please look around, and take a look at my work, my thoughts or more general information about myself.


If you have any questions regarding consulting, licensing of games, or anything else, feel free to email me at lucas@lucasmeijer.com

Contact Info

Lucas Meijer
lucas@lucasmeijer.com
lucasmeijer on twitter
ljmeijer on skype