mirror of
https://github.com/EsotericSoftware/spine-runtimes.git
synced 2026-03-05 10:16:54 +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
@ -161,10 +161,20 @@ namespace Spine.Unity {
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
bool isBinary = skeletonJSON.name.ToLower().Contains(".skel");
|
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 UNITY_EDITOR
|
||||||
if (skeletonJSON) {
|
if (loadedSkeletonData == null && !quiet && skeletonJSON != null) {
|
||||||
SkeletonDataCompatibility.VersionInfo fileVersion = SkeletonDataCompatibility.GetVersionInfo(skeletonJSON);
|
SkeletonDataCompatibility.VersionInfo fileVersion = SkeletonDataCompatibility.GetVersionInfo(skeletonJSON);
|
||||||
CompatibilityProblemInfo compatibilityProblemInfo = SkeletonDataCompatibility.GetCompatibilityProblemInfo(fileVersion);
|
CompatibilityProblemInfo compatibilityProblemInfo = SkeletonDataCompatibility.GetCompatibilityProblemInfo(fileVersion);
|
||||||
if (compatibilityProblemInfo != null) {
|
if (compatibilityProblemInfo != null) {
|
||||||
@ -173,20 +183,9 @@ namespace Spine.Unity {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
if (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);
|
|
||||||
return null;
|
return null;
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
if (skeletonDataModifiers != null) {
|
if (skeletonDataModifiers != null) {
|
||||||
foreach (var m in skeletonDataModifiers) {
|
foreach (var m in skeletonDataModifiers) {
|
||||||
if (m != null) m.Apply(loadedSkeletonData);
|
if (m != null) m.Apply(loadedSkeletonData);
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user