I'm trying to convert this code from UnityScript (Unity's version of JavaScript) to C#:
var polys = new Array(); // array to collect vertex locations
polys.Push((scanpoint + padding) + Vector2(0.5, 0.5) * Pixel_vs_Unit_Scale);
var poly:Vector2[] = polys.ToBuiltin(Vector2);
I converted the first two lines like so, with no errors:
var polys = new List<Vector2>();
polys.Add((scanpoint + padding) + new Vector2(0.5f, 0.5f) * Pixel_vs_Unit_Scale);
But when I try to adapt the last line like this:
Vector2[] poly = polys.ToBuiltin(Vector2);
I get two errors:
ToBuiltin does not exist.
And also an error on the Vector2
inside the ()
:
Vector2 is a type which is not valid in the given context.
How can I convert this code to C# correctly?