错误 - SpriteFont 未实现

Error - SpriteFont not implemented

我正在尝试在 Monogame 程序中绘制文本。我想使用 SpriteFont 来完成它,但是在尝试加载 SpriteFont 时出现以下错误。

//Here I try to load the SpriteFont
//It is kept in the "Content/fonts" folder, with "Content" as the Content.RootDirectory
Font = Content.Load<SpriteFont>("fonts/SpriteFont1");

//I then get this error
An unhandled exception of type 'System.NotImplementedException' occurred in MonoGame.Framework.dll
Additional information: The method or operation is not implemented.

SpriteFont1 构建操作设置为 "Content",复制到输出目录为 "Copy Always"。 SpriteFont1.xnb 文件位于 Content 文件夹中,具有相同的设置。如何修复错误以便加载 SpriteFont?

简单修复。根据堆栈跟踪(感谢 Richard Schneider),我发现 SpriteFont1.xnb 文件需要与实际的 .SpriteFont 文件位于同一文件夹中。

实际上,只需要 .xnb 文件,因为它是从 .SpriteFont 编译而来的,所以您应该只将 .xnb 文件复制到 Content 文件夹。

NotImplementedException是因为LoadContent没有实现直接加载.SpriteFont文件。 (在 MonoGame 3.5 中测试)