Exemple #1
0
    private IEnumerator PlaneToCircle()
    {
        Mesh target;

        Vector3[] vertices = new Vector3[m_Width * m_Height];
        Vector2[] uvs      = new Vector2[m_Width * m_Height];
        target           = ProceduralMesh.GenerateCurvedCylinderSegment(m_Height, m_Width, 1.0f, 0.75f);
        m_Mesh.bounds    = target.bounds;
        m_Mesh.triangles = target.triangles;
        float time = 0.0f;

        while (Vector3.Distance(m_Mesh.vertices[0], target.vertices[0]) != 0.0f)
        {
            if (!m_Paused)
            {
                m_BorderAlpha = 1.0f - Mathf.Clamp(Vector3.Distance(m_Mesh.vertices[0], target.vertices[0]), 0.0f, 1.0f);
                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    = 1.0f;
        m_Mesh.vertices  = target.vertices;
        m_Mesh.triangles = target.triangles;
        m_Mesh.uv        = target.uv;
        m_Mesh.normals   = target.normals;
        m_IsPlane        = false;
    }