mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-02-06 07:14:55 +08:00
[unity] Fixed unnecessary additional GC allocation of JSON deserializer in Editor (always caused allocation for version check). Closes #1608.
This commit is contained in:
parent
d252df7ece
commit
ed40731684
@ -114,7 +114,7 @@ namespace Spine.Unity {
|
||||
Clear();
|
||||
return null;
|
||||
}
|
||||
|
||||
|
||||
// Disabled to support attachmentless/skinless SkeletonData.
|
||||
// if (atlasAssets == null) {
|
||||
// atlasAssets = new AtlasAsset[0];
|
||||
@ -161,10 +161,20 @@ namespace Spine.Unity {
|
||||
#endif
|
||||
|
||||
bool isBinary = skeletonJSON.name.ToLower().Contains(".skel");
|
||||
SkeletonData loadedSkeletonData;
|
||||
SkeletonData loadedSkeletonData = null;
|
||||
|
||||
try {
|
||||
if (isBinary)
|
||||
loadedSkeletonData = SkeletonDataAsset.ReadSkeletonData(skeletonJSON.bytes, attachmentLoader, skeletonDataScale);
|
||||
else
|
||||
loadedSkeletonData = SkeletonDataAsset.ReadSkeletonData(skeletonJSON.text, attachmentLoader, skeletonDataScale);
|
||||
} catch (Exception ex) {
|
||||
if (!quiet)
|
||||
Debug.LogError("Error reading skeleton JSON file for SkeletonData asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
|
||||
}
|
||||
|
||||
#if UNITY_EDITOR
|
||||
if (skeletonJSON) {
|
||||
if (loadedSkeletonData == null && !quiet && skeletonJSON != null) {
|
||||
SkeletonDataCompatibility.VersionInfo fileVersion = SkeletonDataCompatibility.GetVersionInfo(skeletonJSON);
|
||||
CompatibilityProblemInfo compatibilityProblemInfo = SkeletonDataCompatibility.GetCompatibilityProblemInfo(fileVersion);
|
||||
if (compatibilityProblemInfo != null) {
|
||||
@ -173,20 +183,9 @@ namespace Spine.Unity {
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
try {
|
||||
if (isBinary)
|
||||
loadedSkeletonData = SkeletonDataAsset.ReadSkeletonData(skeletonJSON.bytes, attachmentLoader, skeletonDataScale);
|
||||
else
|
||||
loadedSkeletonData = SkeletonDataAsset.ReadSkeletonData(skeletonJSON.text, attachmentLoader, skeletonDataScale);
|
||||
|
||||
} catch (Exception ex) {
|
||||
if (!quiet)
|
||||
Debug.LogError("Error reading skeleton JSON file for SkeletonData asset: " + name + "\n" + ex.Message + "\n" + ex.StackTrace, this);
|
||||
if (loadedSkeletonData == null)
|
||||
return null;
|
||||
|
||||
}
|
||||
|
||||
if (skeletonDataModifiers != null) {
|
||||
foreach (var m in skeletonDataModifiers) {
|
||||
if (m != null) m.Apply(loadedSkeletonData);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user