ContentPathGenerator.tt keeps the extension when it's not needed
I got a structure that looks like this
Root
| ContentPathGenerator.tt
| Content
| textures
| logo
| studio
| black.png
| ...
so the template generates something like this:
class Content
{
public static class Textures
{
public static class Logo
{
public static class Studio
{
public const string Black = @"Content\textures\logo\studio\black.png";
}
}
public const string Ball = @"Content\textures\ball.png";
}
public const string Content = @"Content.mgcb";
}
}
But when I use it, i get an error :
FileNotFoundException : Could not find file '[...]\bin\Debug\net8.0\Content\textures\logo\studio\black.png.xnb'.
Because the real file path is
[...]\bin\Debug\net8.0\Content\textures\logo\studio\black.xnb
The file extension is removed at Content compile time but the template doesn't seem to take that into account..
How could it be fixed?
I found somewhat of a fix for this.. in PrintContentFiles, just before the WriteLine, i put
finalPath = finalPath.Substring(0, finalPath.IndexOf(".") + 1);
finalPath = finalPath.Replace(".", string.Empty);
so it removes everything after the first "." it finds... The problem is if your file has a "." in the name that is not the extension
Nez doesnt generally use XNB files for textures. You can load the PNG directly via the NezContentManager and the usual png extension.
Nez doesnt generally use XNB files for textures. You can load the PNG directly via the NezContentManager and the usual png extension.
That's what I think I do but I'm not sure if I do it correctly Here is the code :
var logoTexture = Content.Load<Texture2D>(Nez.ContentPath.Textures.Logo.Studio.Black);
you should use Content.LoadTexture()