As a side question, are multidimensional builtin arrays as fast in Unity as single-dimensional builtin arrays? I'd rather have performance and a little extra coding...
Sure, you'd probably simply add this static method to the C# script:
... so that would be for a 2-dimensional one ... for 3-dimensional, you'd add:
Regarding the question of performance: I'm pretty sure there is no performance difference between one-dimensional arrays and multi-dimensional ones. Of course, creating those arrays will likely take a little longer because usually they have more "space" so more memory needs to be allocated and managed. But writing/reading into/from those arrays shouldn't take a significant amount of time.
Of course, it depends on how "much" you do of it. As a rule of thumb: If it's just once per frame: Don't worry. If you're looping or doing nested loops in each frame: Watch out.
As with anything that has to do with performance: "Premature optimization is the root of all evil" (Donald Knuth). See also: Wikipedia: Program Optimization - When to optimize
You can make a new class containing an array of vector3's
You can then create an array of ThreeVecs:
Just one possible way. :)
so a class to answer your question below and illustrate using the constructor to initialise:
Multi-dimensional arrays are slightly slower than 1-dimensional arrays. It's unlikely to make any difference in practice though.
answered Aug 05 '10 at 02:43 PM