Exemplo n.º 1
0
    public void InitModeMesh()
    {
        if (!isDrawMesh)
        {
            if (meshPoints != null)
            {
                meshPoints.Clear();
            }
            return;
        }

        if (meshFilter == null)
        {
            meshFilter = GetComponent <MeshFilter>();
        }

        if (meshFilter == null)
        {
            MyDebug.LogRed("meshFilter == null");  return;
        }

        Mesh mesh = meshFilter.sharedMesh;

        List <string> pointStrings = new List <string>();

        if (mesh == null)
        {
            return;
        }

        for (int i = 0; i < mesh.vertices.Length; i++)
        {
            string vstr = Vector2String(this.transform.TransformPoint(mesh.vertices[i]));

            if (!pointStrings.Contains(vstr))
            {
                pointStrings.Add(vstr);
            }
        }

        if (meshPoints == null)
        {
            meshPoints = new List <Vector3>();
        }

        meshPoints.Clear();

        for (int i = 0; i < pointStrings.Count; i++)
        {
            meshPoints.Add(String2Vector(pointStrings[i]));
        }
    }