无法从使用中推断出方法'Microsoft.Xna.Framework.Graphics.VertexBuffer.SetData <t>(T [])'的类型参数</t>

时间:2012-02-26 19:40:34

标签: c# xna

我有:

    public List<VertexPositionColor> chunk_vertices;
    public List<int> chunk_indices;

然后

VertexBuffer vertex_buffer;
vertex_buffer = new VertexBuffer(device, VertexPositionColor.VertexDeclaration, test_chunk.chunk_vertices.Count, BufferUsage.WriteOnly);

vertex_buffer.SetData(test_chunk.chunk_vertices);

我试过了:

vertex_buffer.SetData<VertexPositionColor>(test_chunk.chunk_vertices);

vertex_buffer.SetData<List<VertexPositionColor>>(test_chunk.chunk_vertices);

1 个答案:

答案 0 :(得分:3)

VertexBuffer.SetData方法需要一个数组,因此将chunk_vertices更改为数组,或使用以下代码:

vertex_buffer.SetData(test_chunk.chunk_vertices.ToArray());