I have this struct:
public struct LevelElements
{
public Texture2D levelTexture;
// other variables...
}
and I initialize it in this way:
for (int i = 0; i < 2; i++)
levelElements[i] = new LevelElements
{
levelTexture = content.Load<Texture2D>("Terrain/level"),
// other variables...
}
Then I draw the first texture while modifying it with textureLevel.SetData
method.
The problem is that if I draw the second one it looks the same as the modified first one, and not as the original one loaded from the content.
Why have both levelTexture
s the same reference? Doesn't Content.Load<Texture2D>()
create a new instance?
PS: I don't need to create a copy of that texture, I was only testing my code and I found this behaviour.