Merge branch '4.0' into 4.1-beta

This commit is contained in:
Harald Csaszar 2021-11-24 15:39:48 +01:00
commit ac73dc5857

View File

@ -96,8 +96,7 @@ namespace Spine.Unity {
if (hasBinaryExtension) { if (hasBinaryExtension) {
problemDescription = string.Format("Failed to read '{0}'. Extension is '.skel.bytes' but content looks like a '.json' file.\n" problemDescription = string.Format("Failed to read '{0}'. Extension is '.skel.bytes' but content looks like a '.json' file.\n"
+ "Did you choose the wrong extension upon export?\n", asset.name); + "Did you choose the wrong extension upon export?\n", asset.name);
} } else {
else {
problemDescription = string.Format("Failed to read '{0}'. Extension is '.json' but content looks like binary 'skel.bytes' file.\n" problemDescription = string.Format("Failed to read '{0}'. Extension is '.json' but content looks like binary 'skel.bytes' file.\n"
+ "Did you choose the wrong extension upon export?\n", asset.name); + "Did you choose the wrong extension upon export?\n", asset.name);
} }
@ -110,19 +109,16 @@ namespace Spine.Unity {
using (var memStream = new MemoryStream(asset.bytes)) { using (var memStream = new MemoryStream(asset.bytes)) {
fileVersion.rawVersion = SkeletonBinary.GetVersionString(memStream); fileVersion.rawVersion = SkeletonBinary.GetVersionString(memStream);
} }
} } catch (System.Exception e) {
catch (System.Exception e) {
problemDescription = string.Format("Failed to read '{0}'. It is likely not a binary Spine SkeletonData file.\n{1}", asset.name, e); problemDescription = string.Format("Failed to read '{0}'. It is likely not a binary Spine SkeletonData file.\n{1}", asset.name, e);
isSpineSkeletonData = false; isSpineSkeletonData = false;
return null; return null;
} }
} } else {
else {
Match match = jsonVersionRegex.Match(asset.text); Match match = jsonVersionRegex.Match(asset.text);
if (match != null) { if (match != null) {
fileVersion.rawVersion = match.Groups[1].Value; fileVersion.rawVersion = match.Groups[1].Value;
} } else {
else {
object obj = Json.Deserialize(new StringReader(asset.text)); object obj = Json.Deserialize(new StringReader(asset.text));
if (obj == null) { if (obj == null) {
problemDescription = string.Format("'{0}' is not valid JSON.", asset.name); problemDescription = string.Format("'{0}' is not valid JSON.", asset.name);
@ -156,8 +152,7 @@ namespace Spine.Unity {
try { try {
fileVersion.version = new[]{ int.Parse(versionSplit[0], CultureInfo.InvariantCulture), fileVersion.version = new[]{ int.Parse(versionSplit[0], CultureInfo.InvariantCulture),
int.Parse(versionSplit[1], CultureInfo.InvariantCulture) }; int.Parse(versionSplit[1], CultureInfo.InvariantCulture) };
} } catch (System.Exception e) {
catch (System.Exception e) {
problemDescription = string.Format("Failed to read version info at skeleton '{0}'. It is likely not a valid Spine SkeletonData file.\n{1}", asset.name, e); problemDescription = string.Format("Failed to read version info at skeleton '{0}'. It is likely not a valid Spine SkeletonData file.\n{1}", asset.name, e);
isSpineSkeletonData = false; isSpineSkeletonData = false;
return null; return null;
@ -179,9 +174,11 @@ namespace Spine.Unity {
if (char.IsWhiteSpace(c)) if (char.IsWhiteSpace(c))
continue; continue;
if (!openingBraceFound) { if (!openingBraceFound) {
if (c == '{') openingBraceFound = true; if (c == '{' || c == '[') openingBraceFound = true;
else return false; else return false;
} else } else if (c == '{' || c == '[' || c == ']' || c == '}' || c == ',')
continue;
else
return c == '"'; return c == '"';
} }
return true; return true;