- Home /
Unable To capture Vertex buffer stream Unity 2020 MeshData API
Hi all Thanks for taking a look , I'm using the new Mesh.MeshData api and im battling to get the mesh to build correctly , I so far am able to apply the vertices trianlges and normals but am unable to get the uvs and colors to apply correctly , please can someone give me pointers on what im doing wrong Thanks again. The code Says unable to capture vert buffer stream its referencing the colors and uvs (stream 2 and stream 3) Heres the code int T = Tris.Count; var data = outputMesh[0]; data.SetVertexBufferParams(size, new VertexAttributeDescriptor(VertexAttribute.Position), new VertexAttributeDescriptor(VertexAttribute.Normal, stream: 1), new VertexAttributeDescriptor(VertexAttribute.Color, stream: 2), new VertexAttributeDescriptor(VertexAttribute.TexCoord0, stream: 3)); data.SetIndexBufferParams(T, IndexFormat.UInt32); NativeArray<Vector3> NVerts; NVerts = data.GetVertexData<Vector3>(stream: 0); NativeArray<Vector3> NNormals; NNormals = data.GetVertexData<Vector3>(stream: 1); NativeArray<Color32> NColors; NColors = data.GetVertexData<Color32>(stream: 2);//colors are also incorrect NativeArray<Vector2> NUVs; NUVs = data.GetVertexData<Vector2>(stream: 3);//Uvs says unable to capture vertex buffer stream and they are incorrect NativeArray<int> NTris; NTris = data.GetIndexData<int>(); int vCount = NVerts.Length; for(int i =0;i < vCount; i++) { NVerts[i] = tempVerts[i]; NNormals[i] = tempNormals[i]; NColors[i] = color[i]; NUVs[i] = tUvs[i]; } for (int i = 0; i < T; i++) { NTris[i] = Tris[i]; } var sm = new SubMeshDescriptor(0, T, MeshTopology.Triangles); sm.firstVertex = 0; sm.vertexCount = size; data.subMeshCount = 1; data.SetSubMesh(0, sm);
Your answer
