From fbcd00d41af6785c4d45262ccdd16caa14a32dd1 Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Wed, 1 Apr 2020 15:18:34 +0200 Subject: [PATCH 1/3] [unity] Replaced full json parsing for version string in `SkeletonDataCompatibility.GetVersionInfo()` with lightweight regex variant (fallback to full parsing). Affects editor only, built binary always excluded GetVersionInfo() checks. --- .../Asset Types/SkeletonDataCompatibility.cs | 38 ++++++++++++------- 1 file changed, 24 insertions(+), 14 deletions(-) diff --git a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs index 68b78f57c..d072a31c7 100644 --- a/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs +++ b/spine-unity/Assets/Spine/Runtime/spine-unity/Asset Types/SkeletonDataCompatibility.cs @@ -30,7 +30,10 @@ using System.Collections.Generic; using System.IO; using UnityEngine; +#if UNITY_EDITOR using System.Globalization; +using System.Text.RegularExpressions; +#endif namespace Spine.Unity { @@ -41,6 +44,7 @@ namespace Spine.Unity { static readonly int[][] compatibleJsonVersions = { new[] { 3, 8, 0 } }; static bool wasVersionDialogShown = false; + static readonly Regex jsonVersionRegex = new Regex(@"""spine""\s*:\s*""([^""]+)""", RegexOptions.CultureInvariant); #endif public enum SourceType { @@ -92,23 +96,29 @@ namespace Spine.Unity { } } else { - object obj = Json.Deserialize(new StringReader(asset.text)); - if (obj == null) { - Debug.LogErrorFormat("'{0}' is not valid JSON.", asset.name); - return null; + Match match = jsonVersionRegex.Match(asset.text); + if (match != null) { + fileVersion.rawVersion = match.Groups[1].Value; } + else { + object obj = Json.Deserialize(new StringReader(asset.text)); + if (obj == null) { + Debug.LogErrorFormat("'{0}' is not valid JSON.", asset.name); + return null; + } - var root = obj as Dictionary; - if (root == null) { - Debug.LogErrorFormat("'{0}' is not compatible JSON. Parser returned an incorrect type while parsing version info.", asset.name); - return null; - } + var root = obj as Dictionary; + if (root == null) { + Debug.LogErrorFormat("'{0}' is not compatible JSON. Parser returned an incorrect type while parsing version info.", asset.name); + return null; + } - if (root.ContainsKey("skeleton")) { - var skeletonInfo = (Dictionary)root["skeleton"]; - object jv; - skeletonInfo.TryGetValue("spine", out jv); - fileVersion.rawVersion = jv as string; + if (root.ContainsKey("skeleton")) { + var skeletonInfo = (Dictionary)root["skeleton"]; + object jv; + skeletonInfo.TryGetValue("spine", out jv); + fileVersion.rawVersion = jv as string; + } } } From 24ff3258ec6af6554f3455e6520cb493558c4443 Mon Sep 17 00:00:00 2001 From: Nathan Sweet Date: Wed, 1 Apr 2020 22:38:28 +0200 Subject: [PATCH 2/3] [libgdx] Fixed AnimationState tests. Commit a321aa76d556a618a09abb3adeb7473a6c099304 added "|| timeline instanceof EventTimeline" to `computeHold`, so event timelines always use FIRST, never HOLD. This changed the timing slightly and broke the test, but the new timing is better. --- .../com/esotericsoftware/spine/AnimationStateTests.java | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java index df1fa6d0f..7860c9f16 100644 --- a/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java +++ b/spine-libgdx/spine-libgdx-tests/src/com/esotericsoftware/spine/AnimationStateTests.java @@ -37,6 +37,7 @@ import com.badlogic.gdx.backends.lwjgl.LwjglFileHandle; import com.badlogic.gdx.math.MathUtils; import com.badlogic.gdx.utils.Array; import com.badlogic.gdx.utils.Pool; + import com.esotericsoftware.spine.AnimationState.AnimationStateListener; import com.esotericsoftware.spine.AnimationState.TrackEntry; import com.esotericsoftware.spine.attachments.AttachmentLoader; @@ -651,14 +652,15 @@ public class AnimationStateTests { expect(0, "start", 0, 0.4f), // expect(0, "event 0", 0.1f, 0.5f), // + + expect(1, "end", 0.8f, 0.9f), // + expect(1, "dispose", 0.8f, 0.9f), // + expect(0, "event 14", 0.5f, 0.9f), // expect(2, "end", 0.8f, 1.1f), // expect(2, "dispose", 0.8f, 1.1f), // - expect(1, "end", 0.8f, 1.1f), // - expect(1, "dispose", 0.8f, 1.1f), // - expect(0, "event 30", 1, 1.4f), // expect(0, "complete", 1, 1.4f), // expect(0, "end", 1, 1.5f), // From 3321751f981214ce3f60f44f21f63cd36095e70e Mon Sep 17 00:00:00 2001 From: Harald Csaszar Date: Mon, 6 Apr 2020 18:01:40 +0200 Subject: [PATCH 3/3] [unity] Added package.json files to support using the spine-unity core runtime and the examples as UPM packages. This could be used to e.g. reduce compile time. See #1276. --- .../Assets/Spine Examples/package.json | 20 +++++++++++++++++++ .../Assets/Spine Examples/package.json.meta | 7 +++++++ .../spine-unity-examples.asmdef | 4 ++++ .../spine-unity-examples.asmdef.meta | 7 +++++++ spine-unity/Assets/Spine/package.json | 19 ++++++++++++++++++ spine-unity/Assets/Spine/package.json.meta | 7 +++++++ 6 files changed, 64 insertions(+) create mode 100644 spine-unity/Assets/Spine Examples/package.json create mode 100644 spine-unity/Assets/Spine Examples/package.json.meta create mode 100644 spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef create mode 100644 spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef.meta create mode 100644 spine-unity/Assets/Spine/package.json create mode 100644 spine-unity/Assets/Spine/package.json.meta diff --git a/spine-unity/Assets/Spine Examples/package.json b/spine-unity/Assets/Spine Examples/package.json new file mode 100644 index 000000000..3924c88d6 --- /dev/null +++ b/spine-unity/Assets/Spine Examples/package.json @@ -0,0 +1,20 @@ +{ + "name": "com.esotericsoftware.spine.spine-unity-examples", + "displayName": "spine-unity Runtime Examples", + "description": "This plugin provides example scenes and scripts for the spine-unity runtime.", + "version": "3.8.0", + "unity": "2018.3", + "author": { + "name": "Esoteric Software", + "email": "contact@esotericsoftware.com", + "url": "http://esotericsoftware.com/" + }, + "dependencies": { + "com.esotericsoftware.spine.spine-unity": "3.8.0" + }, + "keywords": [ + "spine", + "spine-unity", + "core" + ] +} diff --git a/spine-unity/Assets/Spine Examples/package.json.meta b/spine-unity/Assets/Spine Examples/package.json.meta new file mode 100644 index 000000000..9c5cdb952 --- /dev/null +++ b/spine-unity/Assets/Spine Examples/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 3344f01d63135c94e81d853f56d6c4e5 +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef b/spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef new file mode 100644 index 000000000..646178423 --- /dev/null +++ b/spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef @@ -0,0 +1,4 @@ +{ + "name": "spine-unity-examples", + "references": [ "spine-unity" ] +} diff --git a/spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef.meta b/spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef.meta new file mode 100644 index 000000000..f8dc4a556 --- /dev/null +++ b/spine-unity/Assets/Spine Examples/spine-unity-examples.asmdef.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 8f5163e4753269348a069fd2fedcba29 +AssemblyDefinitionImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: diff --git a/spine-unity/Assets/Spine/package.json b/spine-unity/Assets/Spine/package.json new file mode 100644 index 000000000..6fac1264d --- /dev/null +++ b/spine-unity/Assets/Spine/package.json @@ -0,0 +1,19 @@ +{ + "name": "com.esotericsoftware.spine.spine-unity", + "displayName": "spine-unity Runtime", + "description": "This plugin provides the spine-unity runtime core.", + "version": "3.8.0", + "unity": "2018.3", + "author": { + "name": "Esoteric Software", + "email": "contact@esotericsoftware.com", + "url": "http://esotericsoftware.com/" + }, + "dependencies": { + }, + "keywords": [ + "spine", + "spine-unity", + "core" + ] +} diff --git a/spine-unity/Assets/Spine/package.json.meta b/spine-unity/Assets/Spine/package.json.meta new file mode 100644 index 000000000..d0000ccae --- /dev/null +++ b/spine-unity/Assets/Spine/package.json.meta @@ -0,0 +1,7 @@ +fileFormatVersion: 2 +guid: 09478c42aa0375347898d942d287a819 +PackageManifestImporter: + externalObjects: {} + userData: + assetBundleName: + assetBundleVariant: