Ejemplo n.º 1
0
        public Mesh CreateMesh(GameObject gameObject, Vector2 UVScale, Vector2 UVOffset, PolygonTriangulator2D.Triangulation triangulation = PolygonTriangulator2D.Triangulation.Advanced)
        {
            if (gameObject.GetComponent <MeshRenderer>() == null)
            {
                gameObject.AddComponent <MeshRenderer>();
            }

            MeshFilter filter = gameObject.GetComponent <MeshFilter> ();

            if (filter == null)
            {
                filter = gameObject.AddComponent <MeshFilter>() as MeshFilter;
            }

            filter.sharedMesh = PolygonTriangulator2D.Triangulate2D(this, UVScale, UVOffset, triangulation);
            if (filter.sharedMesh == null)
            {
                UnityEngine.Object.Destroy(gameObject);
            }

            return(filter.sharedMesh);
        }
Ejemplo n.º 2
0
 public Mesh CreateMesh(Vector2 UVScale, Vector2 UVOffset, PolygonTriangulator2D.Triangulation triangulation = PolygonTriangulator2D.Triangulation.Advanced)
 {
     return(PolygonTriangulator2D.Triangulate2D(this, UVScale, UVOffset, triangulation));
 }