Example #1
0
    private IEnumerator CircleToPlane()
    {
        Mesh target;

        Vector3[] vertices = new Vector3[m_Width * m_Height];
        Vector2[] uvs      = new Vector2[m_Width * m_Height];
        target = ProceduralMesh.GeneratePlane(m_Height, m_Width);
        float time = 0.0f;

        while (Vector3.Distance(m_Mesh.vertices[0], target.vertices[0]) != 0.0f)
        {
            m_BorderAlpha = Mathf.Clamp(Vector3.Distance(m_Mesh.vertices[0], target.vertices[0]), 0.0f, 1.0f);
            if (!m_Paused)
            {
                for (int i = 0; i < m_Mesh.vertexCount; i++)
                {
                    vertices[i] = Vector3.Lerp(m_Mesh.vertices[i], target.vertices[i], time);
                    uvs[i]      = Vector2.Lerp(m_Mesh.uv[i], target.uv[i], time);
                }
                m_Mesh.vertices = vertices;
                m_Mesh.uv       = uvs;
                time            = (Time.deltaTime / Vector3.Distance(m_Mesh.vertices[0], target.vertices[0])) * m_TimeMultiUp;
            }
            yield return(null);
        }
        m_BorderAlpha    = 0.0f;
        m_Mesh.vertices  = target.vertices;
        m_Mesh.triangles = target.triangles;
        m_Mesh.uv        = target.uv;
        m_Mesh.normals   = target.normals;
        m_Mesh.bounds    = target.bounds;
        m_IsPlane        = true;
    }
Example #2
0
    // Use this for initialization
    void Start()
    {
        m_Mesh = ProceduralMesh.GeneratePlane(m_Height, m_Width);

        m_Filter.mesh = m_Mesh;
    }