Exemple #1
0
        public void Build(MeshFilter meshFilter)
        {
    #if UNITY_EDITOR
            Mesh mesh = meshFilter.sharedMesh;
    #else
            Mesh mesh = meshFilter.mesh;
    #endif
            if (mesh == null)
            {
                mesh = new Mesh();

                if (Dynamic)
                {
                    mesh.MarkDynamic();
                }
            }

            mesh.Clear();


            // Set verts
            mesh.vertices = Vertices.TrimAndGetBuffer();

            // Set indices
            mesh.triangles = Indices.TrimAndGetBuffer();

            // Set uvs
            mesh.uv = UVs.TrimAndGetBuffer();

            // Set normals
            mesh.normals = Normals.TrimAndGetBuffer();

            // Set Colours
            if (Colours.Count > 0)
            {
                mesh.colors = Colours.TrimAndGetBuffer();
            }

            meshFilter.mesh = mesh;
        }