我想要做的是在较大的texture2d中的某个点处将一个较小的texture2d放入另一个较大的texture2d中。 我试过这个方法:
public void DrawBlock(Texture2D block, int xPos, int yPos)
{
Color[] blockData = new Color[block.Width * block.Height];
Color[] mapData = new Color[map.Width * map.Height];
block.GetData(blockData);
map.GetData(mapData);
for (int x = 0; x < block.Width; x++)
{
for (int y = 0; y < block.Height; y++)
{
mapData[((y + yPos) * map.Width) + (x + xPos)] = blockData[(y * block.Width) + x];
}
}
map.SetData(mapData);
}
然后称之为:
DrawBlock(blockTexture, 10, 10);
但每当我调试时,我都会提示这个错误(指向map.SetData(Color [])):
"You may not call SetData on a resource while it is actively set on the GraphicsDevice. Unset it from the device before calling SetData."
任何帮助将不胜感激,谢谢!