Hello! I’m making this post just in case another tutorial taker encounters this same problem.
I’m taking the Learn > Tutorials > Building 2D Games
Currently at: Chapter 20: Implementing UI with Gum
I made all the changes to TitleScene.cs and tried to run it, but encountered this error:
Error loading "Content\fonts/04B_30_5x.xnb". File not found
Did some Googling, couldn’t find anyone else who encountered it, so I decided to backtrack. I undid all my changes on Lesson 20. But it still wouldn’t run (same error).
After some sanity checks and probing around, I found that the problem was in the MGCB Editor. That file specifically had been “forgotten” for some reason. I redid the “Add > Existing Item…” to link that file again, and reran the test.
That worked, except then a new error was raised:
Error loading "Content\images/background-pattern.png". File not found
Now I of course knew the problem, so I opened up the editor again and—sure enough—another asset had been forgotten. I added that one (also audited to see if any others were lost; they weren’t), and the program was able to run error free.
This is an odd error for two reasons:
I didn’t do anything related to these forgotten files
The program ran fine before I began the lesson
Chapter 20 does open up the MGCB Editor, but it is to ad ui.wav in the audio folder
I definitely did not navigate into the fonts and images folder and delete these file links
Maybe adding the NuGet package for Gum? Does that reconfigure config files?
Why these files?
"background-pattern.png” and “04B_30_5x.spritefont” are in different locations and of different types.
Maybe it’s because they’re the two most recent additions to the content?
It’s a bit of a concern obviously. If anyone knows what causes this then I’d love to know. I’m looking forward to learning MonoGame (coming from Unity) because I want a lower-level design experience that still uses C#. I’m loving it so far, but I don’t want my projects potentially falling apart because the MGCB Editor randomly decides to delete configurations. It was simple to fix in this case, but what if it just “decides” to forget half of a large project with carefully selected property settings?
Just a heads up the MGCB is, problematic, I even made a tool to monitor the content file for changes which outlined the issue of adding, removing, and adding the same file, unfortunately Microsoft said it lacked Lasting Value lol whatever that means.
In short, We, I think are getting the content project back, which was far more pleasing, so, try for now, not to remove and add a file, I am unsure where it stores it and honestly I never tried deleting the content file that might be a faster fix…
This sounds like an MGCB Editor project/configuration issue rather than Gum itself. The assets may still exist on disk but have been removed from the content project or lost their build entries. Re-adding them fixes the immediate problem, but I’d recommend keeping the .mgcb file under version control and checking its changes whenever the editor saves.
Sounds like the age old complaint of, forgetting to hit save in the Mgcb editor before closing it.
Other than the ‘.contentproject’ file being reverted in source control, this is the only reason you might fine files not included in the config file after building.
Building the project will create the .xnb files, but if you close without saving, the config is not updated, and your next build will purge the files not included in the config.
I can at least assure everyone that this is not the case. I’m following the tutorial closely, and the two affected files were included during chapter 18. By the end of that chapter, I ran the project without errors. I also ran it at the start of chapter 20 simply out of habit (again with no errors).
The glitch happened specifically after I tried running it again after following the instructions up to Integrating with the Game Loop, and persisted even after I undid all of my coding changes for the chapter. So the cause would have had to have been one of these steps:
Adding the Gum NuGet Package
Adding UI Sound Effect
Everything before that was just going over theory, and everything after that were coding changes that had no effect on this glitch.
So if someone out there has stumbled onto this page after a Google search because you encountered the same problem (and you’re sure you’ve properly saved the editor) then the culprit is most likely one of two things:
Using VSC’s package manager might cause config file corruption, so check the files after each new package you integrate into your project.
Using the MGCB Editor itself might cause unintended data loss, so do a quick headcount on your content files in the editor vs in your project’s file explorer to make sure everything adds up.
(Oh and one last thing: I’m following this tutorial exactly, and it does not yet have any instructions on version control like Git or BitBucket. As such, there is no possibility that this was caused by a git command gone awry)
I don’t know if this is useful for you, but I’m doing the same tutorial. Since I’m using 3.8.5, I decided to try using the Console Content Pipeline project instead of MGCB. I’m working on the last chapter of the shader right now, and everything is working fine.
Well done forging ahead, we currently have the task of updating the tutorials once the new single project template is out to update the tutorial for 3.8.6 using the new Builder.