Monday, April 19, 2010

Unity Built-in Array Woes

Like any sane programmer, I try to keep a reasonable memory footprint for anything I'm coding. So, like any sane programmer, I write everything in Assembly. No, but seriously, poor performance can ruin any good project.

I've recently begun working on a small game using the Unity game engine. One thing I've noticed is that some of the documentation seems to be a bit behind the latest version of the engine (at least for the Javascript function). One great example being the lightning fast built-in array type.

If you are doing anything that targets the iPhone or lower-end hardware, javascript arrays and hashtables can cripple your program. So, like any responsible programmer, you looked up Which Kind of Array or Collection Should I Use?, tried the built-in type for your Javascript:
var enemies = GameObject[16];

and got an error similar to:
Type 'System.Type' does not support slicing.

I've tried every version of that, but no luck. This *seems* to work:
var enemies : System.Array = System.Array.CreateInstance( GameObject, 16 );

Not quit as elegant, but it works.
Please let me know if any of you figured out a simpler way.

Eureka!

So, I've been trying to figure out what to do with this blog space. Originally, it was a place where I was supposed to make up absurd conspiracy theories under some ridiculous alter-ego. Truth be told, it was fun for a couple of weeks, but I just don't have time anymore, and have lost most of those posts anyway.

The other great challenge is that I already have wedemic.net (not sure that's even active anymore), and I contribute to theblogoftomorrow.com, but I'm thinking it may be time to consolidate down to one place where I can ramble on about various programming techniques I discover.

So, if you are looking for odds-and-ends regarding PHP, SOAP, AJAX, Javascript, Apache/WebDav, and various Linux server tricks, hopefully this will prove a valuable resource.

Feedback is alway welcome. Well, unless you are trying to sell "russian viagra love long time," because I'm not interested. I buy that in bulk, and have plenty to last me through the next one hundred years..... I digress.