prime31 / Nez

Nez is a free 2D focused framework that works with MonoGame and FNA
MIT License
1.81k stars 362 forks source link

Unable to load .png files #266

Closed Roxfall closed 6 years ago

Roxfall commented 7 years ago

This is likely an ID10T error, but bear with me.

I'm following the very first tutorial, and I'm having trouble. Visual Studio is giving me this error when it tries to load a Texture2D, expecting an .xnb file. It doesn't even try to load the png file name I provided. Yet this used to work as of Feb 11, 2016, because that's what it does in this video: https://www.youtube.com/watch?v=ZfVMCbOniV0

Maybe it's a Windows issue.

The line that creates the error is this: var texture = myScene.content.Load("images/darkGreyHex");

Coming in from Unity, this has been a frustrating experience. I can't even follow simple instructions to do a 'hello world' equivalent. The documentation is inadequate and apparently out of date. Should I turn all my png files into xnb files? It is unclear to me how to use the PipelineImporter, I'm guessing that's one of its many functions... but how do I open it? There are no executables to run!

Log spew as follows:

Microsoft.Xna.Framework.Content.ContentLoadException occurred HResult=0x80131500 Message=The content file was not found. Source=MonoGame.Framework StackTrace: at Microsoft.Xna.Framework.Content.ContentManager.OpenStream(String assetName) at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject) at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName) at TestGame2.Game1.Initialize() in E:\NezProjects\Mine\TestGame2\TestGame2\Game1.cs:line 38 at Microsoft.Xna.Framework.Game.DoInitialize() at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior) at TestGame2.Program.Main() in E:\NezProjects\Mine\TestGame2\TestGame2\Program.cs:line 17

Inner Exception 1: FileNotFoundException: Could not find file 'E:\NezProjects\Mine\TestGame2\TestGame2\bin\DesktopGL\AnyCPU\Debug\Content\images\darkGreyHex.xnb'.

Thanks for reading about my pain. :)

Roxfall commented 7 years ago

It's entirely possible that my problem is that I never got FNA and Nez-FNA to install and build correctly. The recursive dependency hell just broke my will to debug what's wrong. One-button install would be really helpful to newbies like myself.

Strackeror commented 7 years ago

All content loaded through content.Load<>() has to be registered in the Content.mgcb file, which transforms resouce files into xnb files during compilation. Use the monogame pipeline tool to open your Content.mgcb and add your png file in there.

Roxfall commented 7 years ago

I think something is wrong with my installation, there is no executable for the pipeline tool. Please advise?

On Aug 3, 2017 7:54 AM, "Rémi Lavergne" notifications@github.com wrote:

All content loaded through content.Load<>() has to be registered in the Content.mgcb file, which transforms resouce files into xnb files during compilation. Use the monogame pipeline tool to open your Content.mgcb and add your png file in there.

— You are receiving this because you authored the thread. Reply to this email directly, view it on GitHub https://github.com/prime31/Nez/issues/266#issuecomment-319947830, or mute the thread https://github.com/notifications/unsubscribe-auth/AdQL982SVkEjIRILWVESReXbEULEW2qXks5sUbTqgaJpZM4OryiW .

Strackeror commented 7 years ago

The tool is part of monogame, not nez, you should find it in your monogame install

jbhaywood commented 7 years ago

You can definitely load .png images directly, just as you're trying to do in your question. Here's a couple things to check... Have you set the .png to copy to the output folder in Visual Studio? Have you tried just continuing past the error? Like someone else said, this is a Monogame error, but Nez should still load the file after going past it. I've configured Visual Studio to ignore those errors in my project.