public static QuadrangleMesh AddQuadrangle(Vector3 position, IList <Vector2> verts, Space space = Space.World, Material meshMat = null, bool attachRigidbody = true) { GameObject quad = new GameObject(); quad.transform.position = position + (space == Space.World ? (Vector3)(verts[0] + verts[1] + verts[2] + verts[3]) * 0.25f : Vector3.zero); QuadrangleMesh quadComponent = quad.AddComponent <QuadrangleMesh>(); quadComponent.Build(verts, meshMat); if (attachRigidbody) { quad.AddComponent <Rigidbody2D>(); } return(quadComponent); }
//convert to quad public QuadrangleMesh ToQuad(bool attachRigidbody = true) { return(QuadrangleMesh.AddQuadrangle(transform.position, MeshHelper.ConvertVec3ToVec2(Vertices), Space.World, C_MR.material, attachRigidbody)); }