• Editor
  • Applying Spine JSON output to Unity Skeleton Data.

I've successfully imported the Spine run-times into Unity, and in the absence of instructions (which I probably just haven't found yet) I've attempted to get an animation going.

I've gotten as far as creating an atlas in TexturePacker, importing it, applying it to a "Spine Atlas", and applying that atlas to a "Spine Skeleton Data" asset.

But, no matter how I export it from Spine, the skeleton data won't accept my JSON file. When I drag the JSON asset over the skeleton data, I get a 'circle with line through' cursor, and the JSON doesn't show up in the list that opens when I browse from the property area.

Any help at all is appreciated.

Related Discussions
...
  • Düzenlendi

Hmm strange. I didn't have this problem. I exported without pretty print and added .txt to the end of the json file. I'm using Unity 4.0. Hope you get it worked out.

Unity requires you to add .txt to the file names. I tried to work around this, but in the end I had to give in. It seems it's a typical thing with Unity, maybe they'll improve it at some point.

Your suggestions to replace the JSON file's extension with "txt" worked.

Thank you very much. 😃

We now have a fully operational workflow from Spine to Unity.

Juktec yazdı

Your suggestions to replace the JSON file's extension with "txt" worked.

Thank you very much. 😃

We now have a fully operational workflow from Spine to Unity.

I would really like to see how this works if you feel like making a video. I can't for the life of me wrap my head around this whole runtime business yet and I'm sure there are others in the dark, too.

Yea this has been a bit of a pain for my team lately especially when dealing with a large number of skeleton outputs. It's pretty easy for someone to forget to change the extension or commit the .json extension. I think I'm going to write a quick Unity Editor script to rename the files from .json to .txt.

Unity really should allow an editor field to pick a file based on file extension instead of forcing .txt.

Yea i think they allow .txt and .xml by default. Here is a quick editor script to rename any .json files in your unity project to .txt.

If you put it in your "Editor" folder it should add a drop down that is pretty quick to hit.

   [MenuItem("Utils/Rename Json->txt")]
	static public void RenameJsonToTxt()
	{
		string dataPath = Application.dataPath;
		
	string[] fileNames = Directory.GetFiles(dataPath, "*.json", SearchOption.AllDirectories);

	foreach(string jsonFileName in fileNames)
	{
		string txtFileName = Path.ChangeExtension(jsonFileName, ".txt");
		
		if(File.Exists(txtFileName))
			File.Delete(txtFileName);
		
		File.Move(jsonFileName, txtFileName);
	}
	
	Debug.Log("Renamed " + fileNames.Length + " .json files to .txt");
}