How do you make a (Vector3) Collection in Boo?

I would like to create a (Vector3), which is evidently somehow different from a List[of Vector3], in Boo.

Ultimately, my goal is to procedurally create a mesh. Here’s what I tried at first:

GetComponent[of MeshFilter]().mesh.vertices = [Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(1, 1, 0)]

That didn’t work, so I tried adding on as List[of Vector3].

GetComponent[of MeshFilter]().mesh.vertices = [Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(1, 1, 0)] as List[of Vector3]

Tried casting straight to a (Vector3) like this:

GetComponent[of MeshFilter]().mesh.vertices = [Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(1, 1, 0)] as (Vector3)

The compiler doesn’t complain in this case, but it also doesn’t show anything. How about just making an empty (Vector3)?

myEmptyCollection as (Vector3) = (Vector3)()

Ha, no, that gives me the error that it can’t convert from a UnityEngine.Vector3 to a (UnityEngine.Vector3).

It seems the only way I can even work with a Vector3 is to grab an existing one and manipulate it. (Vector3) can have its members accessed by index, and you can get its length with .Length, but it doesn’t seem to have anything along the lines of Add or Append or Remove or anything else that might let you manipulate how many objects it contains.

For my final trick, I give you this:

dir(GetComponent[of MeshFilter]().mesh.vertices)

Unknown identifier: ‘dir’.

Cool. So they decided to remove key features of the language, such as dir, and rather than use native collections, they decided to make their own collection type which can only be identified by the () around the name of what it holds (which makes it impossible to find documentation on).

Edit:

I did some more research and learned that I can do .GetType().GetMethods() which works a lot like dir. I printed out all the methods and found one was called get_IsFixedLength, ran it, and found that it was a fixed length. So that rules out trying to manipulate existing collections (or any value in making an empty collection, since I suppose that that too would be empty).

So now I really need to know… how do I make a (Vector3) in Boo!?

Edit 2X: Investigated casting a list of Vector3 to (Vector3) again and found that it actually returns a (Vector3) of length 0… so that’s actually my most promising lead so far!

Haven’t really used Boo before but it seems like this should work for you:

i as (Vector3) = (Vector3(0, 0, 1), Vector3(0, 1, 0), Vector3(1, 0, 0))
j as (Vector3) = array(Vector3, 10)

Scribe

I found it!

This is actually pretty simple, but completely impossible to Google for since the important characters are punctuation. To make a (Vector3) instead of a List[of Vector3] just replace the [] with ().

So for my specific example, you use:

GetComponent[of MeshFilter]().mesh.vertices = (Vector3(0, 0, 0), Vector3(1, 0, 0), Vector3(0, 1, 0), Vector3(1, 1, 0))

I must tip my hat to rutter at StackOverflow who answered this (I posted over there after realizing how dead the Boo tag on Unity Answers was): unity game engine - Boo Lists - Cast to (int)? - Stack Overflow