I know that a texture's name is not preserved when it's loaded in. I also know that you can give it a name. For example:
Texture2D texture = content.Load<Texture2D>("MyTexture"); texture.Name = "MyTexture"; //Or whatever else you want to call it
However, what about when you load a model? It automatically loads in the right texture for each ModelMeshPart, and drops the Name (no idea why though). This is fine, right up until the point where you actually want to identify which texture that ModelMeshPart is using. I found someone else having the same problem here. Shawn Hargreaves gave this solution:
If you need access to this data at runtime, you will need to extend the pipeline to store it somewhere else. For instance you could use a custom processor to store texture filenames in the ModelMeshPart.Tag property
I figured that was easy enough. Yeah...feel free to point and laugh. I got as far as creating a custom proccessor class and inheriting the standard ModelProcessor before I realised that I didn't know exactly where the ModelMeshPart's texture was stored and I've spent the past few days trying to find out.
I just want to preserve each part's texture name so that I can do something like
Model model = content.Load<Model>("MyModel"); BasicEffect effect = (BasicEffect)model.Meshes.MeshParts.Effect; string texName = effect.Texture.Name;
Also Merry Christmas.
For the record, I'm importing a .x model.