/// <summary> /// Change the current texture to another one. /// </summary> /// <param name="texturePath">Path of the texture.</param> public void ChangeTexture(string texturePath) { //Remove texture data if needed. TextureHeap.Remove(this); //Set the texture path, and get the MD5SUM. Md5Sum = CalculateMD5(texturePath); TexturePath = texturePath; //Add this texture to the heap. TextureHeap.Add(this, Color.White); }
/// <summary> /// Dispose. /// </summary> public void Dispose() { //Remove resources. if (!Disposed) { //Remove the texture from the heap. TextureHeap.Remove(this); //Disposed. Disposed = true; } }
/// <summary> /// Change the current texture to another one. /// </summary> /// <param name="color">Color to change to.</param> public void ChangeTexture(Color color) { //Remove texture data if needed. TextureHeap.Remove(this); //Get the Md5Sum, reset path. MemoryStream colorTemp = new MemoryStream(new byte[] { color.A, color.R, color.G, color.B }); Md5Sum = CalculateMD5(colorTemp); TexturePath = null; colorTemp.Dispose(); //Add this texture to the heap. TextureHeap.Add(this, color); }
/// <summary> /// Change the texture data. /// </summary> /// <param name="tex">Texture data.</param> public void ChangeTexture(Texture2D tex) { //Remove texture data if needed. TextureHeap.Remove(this); //Get the Md5Sum, reset path. MemoryStream stream = new MemoryStream(); tex.SaveAsPng(stream, tex.Width, tex.Height); stream.Position = 0; Md5Sum = CalculateMD5(stream); stream.Dispose(); TexturePath = null; //Add this texture to the heap. TextureHeap.Add(this, tex); }