Hello,
I'm having a strange issue I've implemented the Spine runtime in my Monogame Windows DX project, during debug everything runs fine, my animation is working properly but after building project to test on other computer, the exe file simply doesn't respond, no error message or whatsoever.
In my content loader the json and atlas is set to copy and png to build
using System;
using Microsoft.Xna.Framework;
using Microsoft.Xna.Framework.Audio;
using Microsoft.Xna.Framework.Graphics;
using Microsoft.Xna.Framework.Input;
using Microsoft.Xna.Framework.Media;
using Game.Logic;
using Game.GUI;
using MonoGame.Extended;
using MonoGame.Extended.ViewportAdapters;
using Spine;
//Class Game
public static Atlas atlas;
public static SkeletonRenderer skeletonRenderer;
//Initialize()
skeletonRenderer = new SkeletonRenderer(GraphicsDevice);
skeletonRenderer.PremultipliedAlpha = false;
//LoadContent()
atlas = new Atlas("Content/SpineAnimations/skeleton.atlas", new XnaTextureLoader(GraphicsDevice));
// loading the atlas seems to break everything
//My Code
Once I comment the atlas line in the LoadContent() function and remove all reference to the atlas in my project the build exe start to work properly again even if I keep the using Spine reference and the skeletonRenderer. The issue seems to be something that has to do with the StreamReader in the atlas class.
My basic animation loader class :
public class AnimationLoader
{
public Skeleton skeleton;
public AnimationState state;
public Vector2 position;
String animationName = "Angry";
public AnimationLoader()
{
SkeletonJson json = new SkeletonJson(Game.atlas);
json.Scale = 1f;
SkeletonData skeletonData = json.ReadSkeletonData("Content/SpineAnimations/skeleton.json");
// Create the skeleton and animation state
skeleton = new Skeleton(skeletonData);
AnimationStateData stateData = new AnimationStateData(skeleton.Data);
state = new AnimationState(stateData);
// Set the "Idle" animation and let it loop forever
state.SetAnimation(0, "Idle", true);
skeleton.SetSkin("Skin1");
}
.../...
//UPDATE and DRAW
}
Hope you guys can help I really want to use spine in my project !
EDIT I found my solution after looking at the error log in the Windows Event Viewer :
If I manually add the skeleton.png to my build folder everything seems to run fine !
Application: GoGoPlanetDefender.exe
CoreCLR Version: 4.700.20.36602
.NET Core Version: 3.1.7
Description: The process was terminated due to an unhandled exception.
Exception Info: System.Exception: Error reading atlas file: Content/SpineAnimations/skeleton.atlas
System.IO.FileNotFoundException: Could not find file 'F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\bin\Debug\netcoreapp3.1\Content\SpineAnimations\skeleton.png'.
File name: 'F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\bin\Debug\netcoreapp3.1\Content\SpineAnimations\skeleton.png'
at System.IO.FileStream.ValidateFileHandle(SafeFileHandle fileHandle)
at System.IO.FileStream.CreateFileOpenHandle(FileMode mode, FileShare share, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access, FileShare share, Int32 bufferSize, FileOptions options)
at System.IO.FileStream..ctor(String path, FileMode mode, FileAccess access)
at Spine.Util.LoadTexture(GraphicsDevice device, String path) in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Spine\Util.cs:line 64
at Spine.XnaTextureLoader.Load(AtlasPage page, String path) in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Spine\XnaTextureLoader.cs:line 62
at Spine.Atlas.Load(TextReader reader, String imagesDir, TextureLoader textureLoader) in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Spine\Atlas.cs:line 147
at Spine.Atlas..ctor(String path, TextureLoader textureLoader) in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Spine\Atlas.cs:line 90
End of inner exception stack trace
at Spine.Atlas..ctor(String path, TextureLoader textureLoader) in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Spine\Atlas.cs:line 92
at GoGoPlanetDefenderGame.GoGoPlanetDefender.LoadContent() in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Game1.cs:line 196
at GoGoPlanetDefenderGame.GoGoPlanetDefender.Initialize() in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Game1.cs:line 85
at Microsoft.Xna.Framework.Game.DoInitialize()
at Microsoft.Xna.Framework.Game.Run(GameRunBehavior runBehavior)
at GoGoPlanetDefenderGame.Program.Main() in F:\MonPremierCode\Csharp\GoGoPlanetDefenderGame\Program.cs:line 11