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 CreateMesh3D(GameObject gameObject, float zSize, Vector2 UVScale, Vector2 UVOffset, float uvRotation, PolygonTriangulator2D.Triangulation triangulation)
        {
            MeshRenderer meshRenderer = gameObject.GetComponent <MeshRenderer>();

            if (meshRenderer == null)
            {
                meshRenderer = gameObject.AddComponent <MeshRenderer>();
            }

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

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

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

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