torsdag 31. mars 2011

A quick Unity/Boo tip.

If you've been writing any code in Unity 3D you've probably encountered the GetComponent(s) function. For the uninitiated, it allows to you access other components attached to the same GameObject.

This is the usual way to do it:
other = GetComponent[of OtherScript]()

When I first started out with Boo, this sort of bothered me. I use Boo to limit the amount of brackets and semicolons in my life, so I decided to read up on how Boo does Generics. What I found was that you could omit the square-brackets.

other = GetComponent of OtherScript()

Now that looks much, much better.

Don't sleep on these links:

Ingen kommentarer:

Legg inn en kommentar