Open obiwanjacobi opened 3 years ago
Ok, I did some digging and debugging and the problem is that I made a tilemap that references multiple tilesets with multiple images. Tiled outputs a little different structure for these cases. The NullReferenceException was caused by the assumption that tileset.Image would always exist, which in my case is not true. The Image is now on the tile.
I have tried to fix the code in the content pipeline and it compiles and builds content, but there seems to be a problem when calling LoadContent
FileNotFoundException: Could not find file 'C:\Users\marc\source\repos\MonoTiled\MonoTiled\bin\Debug\netcoreapp3.1\Content\Parallax\%1%0%0�%0%0%0%1%0%0%0%0%0%0%0%0.xnb'.
That file name concerns me deeply...
Microsoft.Xna.Framework.Content.ContentLoadException
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 Microsoft.Xna.Framework.Content.ContentReader.ReadExternalReference[T]()
at MonoGame.Extended.Tiled.TiledMapTilesetReader.ReadTileset(ContentReader reader)
at Microsoft.Xna.Framework.Content.ContentTypeReader`1.Read(ContentReader input, Object existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at Microsoft.Xna.Framework.Content.ContentReader.ReadExternalReference[T]()
at MonoGame.Extended.Tiled.TiledMapReader.ReadTilesets(ContentReader reader, TiledMap map)
at MonoGame.Extended.Tiled.TiledMapReader.Read(ContentReader reader, TiledMap existingInstance)
at Microsoft.Xna.Framework.Content.ContentTypeReader`1.Read(ContentReader input, Object existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.InnerReadObject[T](T existingInstance)
at Microsoft.Xna.Framework.Content.ContentReader.ReadObject[T]()
at Microsoft.Xna.Framework.Content.ContentReader.ReadAsset[T]()
at Microsoft.Xna.Framework.Content.ContentManager.ReadAsset[T](String assetName, Action`1 recordDisposableObject)
at Microsoft.Xna.Framework.Content.ContentManager.Load[T](String assetName)
at MonoTiled.TiledParallaxScreen.LoadContent() in C:\Users\marc\source\repos\MonoTiled\MonoTiled\TiledParallaxScreen.cs:line 20
at MonoTiled.GameLoop.LoadContent() in C:\Users\marc\source\repos\MonoTiled\MonoTiled\GameLoop.cs:line 55
at MonoTiled.GameLoop.Initialize() in C:\Users\marc\source\repos\MonoTiled\MonoTiled\GameLoop.cs:line 40
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at MonoTiled.Program.Main() in C:\Users\marc\source\repos\MonoTiled\MonoTiled\Program.cs:line 11
This exception was originally thrown at this call stack:
System.IO.FileStream.ValidateFileHandle(Microsoft.Win32.SafeHandles.SafeFileHandle)
System.IO.FileStream.CreateFileOpenHandle(System.IO.FileMode, System.IO.FileShare, System.IO.FileOptions)
System.IO.FileStream.FileStream(string, System.IO.FileMode, System.IO.FileAccess, System.IO.FileShare, int, System.IO.FileOptions)
Microsoft.Xna.Framework.TitleContainer.PlatformOpenStream(string)
Microsoft.Xna.Framework.TitleContainer.OpenStream(string)
Microsoft.Xna.Framework.Content.ContentManager.OpenStream(string)
My fixes can be seen here: https://github.com/obiwanjacobi/MonoGame.Extended/commit/50badecb71a04da00dc06adb6cf41dce565f1fdb
-Sorry, for the mess of changes most of which are whitespace related. I have several housekeeping tools in my VS that sort usings and replace tabs with spaces etc...
Any insights or suggestions would be greatly appreciated.
Tiled software has changed over the years and thus the code has stagnated. I'm having the code move away from the content pipeline all together this summer. In the mean time if come up with a fix a PR would be welcome.
Any idea why it is trying to load that weird file name (%1%0%0�%0%0%0%1%0%0%0%0%0%0%0%0.xnb
)?
I can see the correct .xnb files in the Content/bin, so it seems the pipeline processing is fine...?
I think it might be a good idea to build an abstraction over the specific Tile Map Editor used. There are a couple and most of them work the same. All you need are deserializers for each specific editor that all generate a common object model...
Just starting out with MonoGame, MonoGame Extended and Tiled, so...
Trying to setup a parallax tile map in Tiled. Building the content pipeline gives an error. I probably do something weird you're not supposed to do. Is it the space in the file name....?
The tile map file:
The tile set file: