Ejemplo n.º 1
0
        public static ConvexSplineMesh AddConvexSpline(Vector3 position, Vector2[] basePoints, float resolution = 0.2f, float?minArea = null, Space space = Space.World, Material meshMat = null, bool attachRigidbody = true)
        {
            GameObject splineShapeMesh = new GameObject();

            ConvexSplineMesh convexSplineMeshComponent = splineShapeMesh.AddComponent <ConvexSplineMesh>();

            convexSplineMeshComponent.Build(basePoints, resolution, minArea, meshMat);
            if (attachRigidbody)
            {
                splineShapeMesh.AddComponent <Rigidbody2D>();
            }

            if (space == Space.Self)
            {
                splineShapeMesh.transform.position = position;
            }
            else
            {
                splineShapeMesh.transform.position = position + convexSplineMeshComponent.CenterShift;
            }

            return(convexSplineMeshComponent);
        }