• EditorBugs
  • 4.3-Beta Exported JSON Won't Import in Unity

  • संपादित

Problem statement

My coworker was invited to try 4.3-Beta, and so we decided to make the switch, as our game still has at least a few months of development left before launch.

It was working fine, but after the most recent update (4.3.12-beta) we find that our exported JSON files no longer load into our Unity project (despite updating the runtimes to the 4.3 beta branch from GitHub).

The error is as follows:

Error reading skeleton JSON file for SkeletonData asset: character_SkeletonData
The given key 'target' was not present in the dictionary.
  at System.Collections.Generic.Dictionary2[TKey,TValue].get_Item (TKey key) [0x0001e] in <27bd554a9f0e46179afd19da1336e638>:0 
  at Spine.SkeletonJson.ReadSkeletonData (System.IO.TextReader reader) [0x007d3] in /Users/tklein/perforce_workspace/Knockout2/game/Knockout2/Assets/Spine/Runtime/spine-csharp/SkeletonJson.cs:223 
  at Spine.Unity.SkeletonDataAsset.ReadSkeletonData (System.String text, Spine.AttachmentLoader attachmentLoader, System.Single scale) [0x00014] in /Users/tklein/perforce_workspace/Knockout2/game/Knockout2/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs:295 
  at Spine.Unity.SkeletonDataAsset.GetSkeletonData (System.Boolean quiet) [0x000a7] in /Users/tklein/perforce_workspace/Knockout2/game/Knockout2/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataAsset.cs:194 
[stack trace omitted for size]

I'm not 100% sure, but it's possible it's related to the export containing a bad version string, e.g. 4.1-from-4.3.12-beta when exported with 4.2 compatibility.

Describe: 1) what you have tried, 2) what you expected, and 3) what actually happened.
We've tried exporting with 4.3, 4.2, and 4.1 compatibility as a JSON file and all exports have the same problem not finding the "target" key. We expect that, using the 4.3 beta runtimes, that we would be able to import and load the 4.3 exported JSON file, but instead get the error above.

Give step-by-step instructions so we can reproduce the problem, if possible.

  1. Load 4.3 runtimes into Unity 6 project.
  2. Make a Spine file with an old Spine version.
  3. Update Spine to latest 4.3 version.
  4. Make changes to Spine file with new Spine version.
  5. (Make changes using new 4.3 Spine features??).
  6. Export Spine file as JSON with 4.3 compatibility.
  7. Attempt to import this Spine file into Unity 6.

Editor information

Tell us your Spine Editor version.
Spine v4.3.12-Beta
Tell us your Spine Runtime version.
Runtime 4.3-beta Branch Revision #66434fe

Related Discussions
...

The issue you're experiencing with the 4.3-beta exported JSON not importing into Unity is likely due to the beta nature of both the Spine editor and the runtime. During beta phases, changes to the export formats, such as the addition of new features or modifications to existing ones, can lead to incompatibilities. The error message you're seeing, related to the 'target' key not being present, suggests that there might be a mismatch between the data structure expected by the runtime and the data being provided by the JSON export.

To address this, ensure that both your Spine editor and runtime are updated to the latest beta versions, as updates may resolve compatibility issues. If the problem persists, consider using JSON exports as they are generally less sensitive to format changes compared to binary exports. However, keep in mind that using beta versions in production can lead to unexpected issues, and it's advisable to test thoroughly before committing to a beta version for a project nearing completion.

Sorry if it wasn't clear, but beta releases may not yet have runtime support:
http://esotericsoftware.com/spine-versioning#Beta-releases

We are actively working on runtime support as well as editor improvements and new features that will likely require more runtime support. There is always a short amount of time between new features and the runtimes being updated. Prior to 4.3.12-beta it was only a coincidence if your exports worked with 4.2 runtimes.

In 4.3.12-beta some naming was revised. Path and transform constraints used to have a "target" slot and bone and that has been renamed to "source" and "slot: to reduces confusion. Previous 4.3 beta versions changed the export format for transform constraints to support mapping properties, and that won't load in a 4.2 runtime either.

I suggest not moving to 4.3 for production unless you can wait for 4.3 to exit beta. Again I apologize if this wasn't clear when we asked for your input on the beta!

    Nate

    Thanks for the quick reply.

    Even when we change the export version to 4.2 or 4.1 though, we are still unable to import that exported JSON into our project, and the spine version listed in the JSON file is: "4.1-from-4.3.07-beta" for both 4.2 and 4.1 version exports.

    Shouldn't we still be able to export and load 4.2 exports?

    Sort of. Development is active during beta and the export from 4.3 to 4.2 doesn't yet have the conversions for the "target" naming. We'll get that done in 4.3.14-beta today.

    Other than that, exporting to an old version is meant only for emergency recovery purposes and isn't a recommended workflow -- there may be data loss. For example, transform constraints in 4.3 have more features (eg mapping rotation to translation) and that can't be fully exported back to 4.2, which lacks those features. In 4.3.14-beta we'll try to keep transform constraints that have "straight across" mappings (eg rotation to rotation) but other mappings would be lost.

    When exporting JSON to an older version, you'll not want to use the JSON directly in a runtime. Instead you'd import it into an older version of Spine, so you have a project file that matches your runtime version, and then continue working on it in the older Spine version.

    Got it. Thanks for the additional info and intended use for the version export setting!

    Guess I've gotta wait for the 4.3.14-beta update later today 😅

    As of this moment, the emergency export to previous editor versions is broken. I thankfully don't use anything that would be lost in the transfer, but I look forward to this being fixed so I can recover some work from when I was testing 4.3. I've been manually editing the json files this afternoon, which is easy, just time-consuming. 🙂

    I understand. We're working on the conversion and will have it done today. The hard part is converting transform constraints back to 4.2 where possible. I feel bad that I've caused you this trouble by not warning about fully switching to the beta. 🤕

    No need to feel bad. It was our fault for not fully realizing the ramifications of updating to a beta version, and our incorrect assumption that the Runtime beta is released in parity with the Editor beta lol

    Yes, PLEASE do not think we're displeased. If anything, we are impressed and grateful as to the speed of your responses. Don't miss dinner for our sake. We have time.

    In fact, I've already text-edited myself out of danger. 🙂

    I don't know what that is exactly, but it's cool! 😎

    I'm glad you aren't blocked anymore at least. I guess you don't have transform constraints, else it would have been a bit tricky to convert with a text editor.

    4.3.13-beta is up now! It converts path slot->target, transform constraint source->target, and the new transform constraint properties to the old offsets, as much as is possible.

    @ExNull-Tyelor @FCSW_Ben FYI, the spine-unity runtime on the 4.3-beta branch has been updated to load 4.3 skeletons from the most recent Spine Editor now. The previous spine-unity 4.3-beta state reading skeletons of version 4.2 was just mirroring the state of the 4.2 branch, without any 4.3-beta changes included yet.

    The first 4.3-beta spine-unity packages are available for download here as usual:
    https://esotericsoftware.com/spine-unity-download
    Please note that as always, any beta (especially when early in development) is not recommended for production use.

    We are currently investigating an issue with negative skeleton scale and Transform Constraint changing behaviour compared to 4.2, so you might want to wait a bit before upgrading your existing projects.

      Harald

      I'm kinda sad that I haven't checkout the forum BEFORE updating all my project to the lastest beta version, but I couldn't wait to try your amazing new addition ! It's my fault anyways, it's a beta.

      Anyways, I didn't actually changed anything on my constraint right now, I could have skipped the beta honestly. (I mean on this project, I tested it on another scene and didn't changed back to 4.2)
      I did it anyway, but now the import in bytes doesn't work for me :

      IndexOutOfRangeException: Index was outside the bounds of the array.
      Spine.SkeletonBinary.ReadSkeletonData (System.IO.Stream file) (at Assets/Plugins/Spine/Runtime/spine-csharp/SkeletonBinary.cs:326)
      Spine.Unity.Editor.AssetUtility.AddRequiredAtlasRegionsFromBinary (System.String skeletonDataPath, System.Collections.Generic.List1[T] requiredPaths) (at Assets/Plugins/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:224)
      Spine.Unity.Editor.AssetUtility.GetRequiredAtlasRegions (System.String skeletonDataPath) (at Assets/Plugins/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:141)
      Spine.Unity.Editor.AssetUtility.ImportSpineContent (System.String[] imported, System.Collections.Generic.List
      1[T] texturesWithoutMetaFile, System.Boolean reimport) (at Assets/Plugins/Spine/Editor/spine-unity/Editor/Utility/AssetUtility.cs:438)
      Spine.Unity.Editor.SkeletonDataAssetInspector.DoReimport () (at Assets/Plugins/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs:698)
      Spine.Unity.Editor.SkeletonDataAssetInspector.OnInspectorGUI () (at Assets/Plugins/Spine/Editor/spine-unity/Editor/Asset Types/SkeletonDataAssetInspector.cs:240)
      UnityEditor.UIElements.InspectorElement+<>cDisplayClass79_0.<CreateInspectorElementUsingIMGUI>b0 () (at <eebf6a509b354512a5d405c8a7dd6f88>:0)
      UnityEngine.GUIUtility😛rocessEvent(Int32, IntPtr, Boolean&)

      The JSON import work fine, so it's fine for me, at least until you solve the problem. I haven't done all my project but I hope it will work on others too.
      I can give you the project, the byte and the JSON if wanted, if it can help you.

      Anyways, the things you added in 4.3 is amazing ! The keysheet, constraint... amazing work. 💯

      • Nate ने इसे लाइक किया।

      @Pentacles Sorry to hear you're having troubles. Please note that the latest 4.3.14-beta version update is less than a day old and contained breaking format changes. Binary exports are always more brittle in this regard than JSON for obvious reasons. The spine-unity runtime has just been updated to reflect the runtime changes accordingly, please give it a try.

      A new spine-unity 4.3-beta unitypackage is available for download here as usual:
      https://esotericsoftware.com/spine-unity-download
      If you are still encountering issues after that, please do let us know.

      • इस पर Pentacles ने जवाब दिया।
      • ExNull-Tyelor ने इसे लाइक किया।

        We are currently investigating an issue with negative skeleton scale and Transform Constraint changing behaviour compared to 4.2, so you might want to wait a bit before upgrading your existing projects.

        FYI: This issue has been fixed in the latest 4.3.14-beta release and the above spine-unity 4.3 runtime package.

        Harald
        Oh, sorry if that wasn't clear, this is clearly my fault, not yours.
        It's Spine beta 4.3 for a reason, using it on project is risky, and I shouldn't have taken the risk to break everything, just to try everything you've added, like a toddler with a new toy 🤣

        I'll wait the official release for updating all my projects to it, but I'll check it out for the newest project !
        I'll get back to you when I'll be on it, if I ever get trouble with it

        • इस पर Harald ने जवाब दिया।

          Pentacles It's Spine beta 4.3 for a reason, using it on project is risky, and I shouldn't have taken the risk to break everything, just to try everything you've added, like a toddler with a new toy 🤣

          That's a funny analogy.😁Hope that doesn't make us bad parents if we hand out dangerous toys without restrictions. 😉

          Pentacles I'll wait the official release for updating all my projects to it, but I'll check it out for the newest project !

          That's very reasonable. Also be sure to keep a copy of your original (4.2) projects around, so you don't lose anything upon upgrading to a new (beta) version in case anything is temporarily broken. I'm sure you do that already, just mentioning in case it helps others.