public (float[] x, float[] y) GetPolygonCollider2DPoints(PolygonCollider2D objects)
{
Vector2[] points = objects.points;
float[] x = new float[points.Length];
float[] y = new float[points.Length];
for (int i = 0; i < points.Length; i++)
{
x[i] = points[i].x;
y[i] = points[i].y;
}
return (x, y);//返回写法
}
(float[] x, float[] y) 确定要返回2个数组
return (x, y);//返回数组的写法
由此可知多个数组函数方法的写法:
(float[] x, float[] y, float[] z)
return (x, y, z);//返回3个数组的写法
返回值的调用:
float[] x;
float[] y;
(x, y)= GetPolygonCollider2DPoints(polygonCollider2D);//调用返回的2个数组