static private ReadSkeletonData ( byte bytes, AttachmentLoader attachmentLoader, float scale ) : |
||
bytes | byte | |
attachmentLoader | AttachmentLoader | |
scale | float | |
return |
public SkeletonData GetSkeletonData(bool quiet) { if (skeletonJSON == null) { if (!quiet) { Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this); } Clear(); return(null); } // Support attachmentless/skinless SkeletonData. // if (atlasAssets == null) { // atlasAssets = new AtlasAsset[0]; // if (!quiet) // Debug.LogError("Atlas not set for SkeletonData asset: " + name, this); // Clear(); // return null; // } // #if !SPINE_TK2D // if (atlasAssets.Length == 0) { // Clear(); // return null; // } // #else // if (atlasAssets.Length == 0 && spriteCollection == null) { // Clear(); // return null; // } // #endif if (skeletonData != null) { return(skeletonData); } AttachmentLoader attachmentLoader; float skeletonDataScale; Atlas[] atlasArray = this.GetAtlasArray(); #if !SPINE_TK2D attachmentLoader = new AtlasAttachmentLoader(atlasArray); skeletonDataScale = scale; #else if (spriteCollection != null) { attachmentLoader = new Spine.Unity.TK2D.SpriteCollectionAttachmentLoader(spriteCollection); skeletonDataScale = (1.0f / (spriteCollection.invOrthoSize * spriteCollection.halfTargetHeight) * scale); } else { if (atlasArray.Length == 0) { Reset(); if (!quiet) { Debug.LogError("Atlas not set for SkeletonData asset: " + name, this); } return(null); } attachmentLoader = new AtlasAttachmentLoader(atlasArray); skeletonDataScale = scale; } #endif bool isBinary = skeletonJSON.name.ToLower().Contains(".skel"); SkeletonData loadedSkeletonData; 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); } this.InitializeWithData(loadedSkeletonData); return(skeletonData); }
/// <summary>Loads, caches and returns the SkeletonData from the skeleton data file. Returns the cached SkeletonData after the first time it is called. Pass false to prevent direct errors from being logged.</summary> public SkeletonData GetSkeletonData(bool quiet) { if (skeletonJSON == null) { if (!quiet) { Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this); } Clear(); return(null); } // Disabled to support attachmentless/skinless SkeletonData. // if (atlasAssets == null) { // atlasAssets = new AtlasAsset[0]; // if (!quiet) // Debug.LogError("Atlas not set for SkeletonData asset: " + name, this); // Clear(); // return null; // } // #if !SPINE_TK2D // if (atlasAssets.Length == 0) { // Clear(); // return null; // } // #else // if (atlasAssets.Length == 0 && spriteCollection == null) { // Clear(); // return null; // } // #endif if (skeletonData != null) { return(skeletonData); } AttachmentLoader attachmentLoader; float skeletonDataScale; Atlas[] atlasArray = this.GetAtlasArray(); #if !SPINE_TK2D attachmentLoader = (atlasArray.Length == 0) ? (AttachmentLoader) new RegionlessAttachmentLoader() : (AttachmentLoader) new AtlasAttachmentLoader(atlasArray); skeletonDataScale = scale; #else if (spriteCollection != null) { attachmentLoader = new Spine.Unity.TK2D.SpriteCollectionAttachmentLoader(spriteCollection); skeletonDataScale = (1.0f / (spriteCollection.invOrthoSize * spriteCollection.halfTargetHeight) * scale); } else { if (atlasArray.Length == 0) { Reset(); if (!quiet) { Debug.LogError("Atlas not set for SkeletonData asset: " + name, this); } return(null); } attachmentLoader = new AtlasAttachmentLoader(atlasArray); skeletonDataScale = scale; } #endif bool hasBinaryExtension = skeletonJSON.name.ToLower().Contains(".skel"); SkeletonData loadedSkeletonData = null; try { if (hasBinaryExtension) { 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, skeletonJSON); } } #if UNITY_EDITOR if (loadedSkeletonData == null && !quiet && skeletonJSON != null) { string problemDescription = null; bool isSpineSkeletonData; SkeletonDataCompatibility.VersionInfo fileVersion = SkeletonDataCompatibility.GetVersionInfo(skeletonJSON, out isSpineSkeletonData, ref problemDescription); if (problemDescription != null) { if (!quiet) { Debug.LogError(problemDescription, skeletonJSON); } return(null); } CompatibilityProblemInfo compatibilityProblemInfo = SkeletonDataCompatibility.GetCompatibilityProblemInfo(fileVersion); if (compatibilityProblemInfo != null) { SkeletonDataCompatibility.DisplayCompatibilityProblem(compatibilityProblemInfo.DescriptionString(), skeletonJSON); return(null); } } #endif if (loadedSkeletonData == null) { return(null); } if (skeletonDataModifiers != null) { foreach (var modifier in skeletonDataModifiers) { if (modifier != null && !(isUpgradingBlendModeMaterials && modifier is BlendModeMaterialsAsset)) { modifier.Apply(loadedSkeletonData); } } } if (!isUpgradingBlendModeMaterials) { blendModeMaterials.ApplyMaterials(loadedSkeletonData); } this.InitializeWithData(loadedSkeletonData); return(skeletonData); }
public SkeletonData GetSkeletonData(bool quiet) { if (atlasAssets == null) { atlasAssets = new AtlasAsset[0]; if (!quiet) { Debug.LogError("Atlas not set for SkeletonData asset: " + name, this); } Clear(); return(null); } if (skeletonJSON == null) { if (!quiet) { Debug.LogError("Skeleton JSON file not set for SkeletonData asset: " + name, this); } Clear(); return(null); } #if !SPINE_TK2D if (atlasAssets.Length == 0) { Clear(); return(null); } #else if (atlasAssets.Length == 0 && spriteCollection == null) { Reset(); return(null); } #endif Atlas[] atlasArr = new Atlas[atlasAssets.Length]; for (int i = 0; i < atlasAssets.Length; i++) { if (atlasAssets[i] == null) { Clear(); return(null); } atlasArr[i] = atlasAssets[i].GetAtlas(); if (atlasArr[i] == null) { Clear(); return(null); } } if (skeletonData != null) { return(skeletonData); } AttachmentLoader attachmentLoader; float skeletonDataScale; #if !SPINE_TK2D attachmentLoader = new AtlasAttachmentLoader(atlasArr); skeletonDataScale = scale; #else if (spriteCollection != null) { attachmentLoader = new Spine.Unity.TK2D.SpriteCollectionAttachmentLoader(spriteCollection); skeletonDataScale = (1.0f / (spriteCollection.invOrthoSize * spriteCollection.halfTargetHeight) * scale); } else { if (atlasArr.Length == 0) { Reset(); if (!quiet) { Debug.LogError("Atlas not set for SkeletonData asset: " + name, this); } return(null); } attachmentLoader = new AtlasAttachmentLoader(atlasArr); skeletonDataScale = scale; } #endif bool isBinary = skeletonJSON.name.ToLower().Contains(".skel"); try { if (isBinary) { skeletonData = SkeletonDataAsset.ReadSkeletonData(skeletonJSON.bytes, attachmentLoader, skeletonDataScale); } else { skeletonData = 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); } stateData = new AnimationStateData(skeletonData); FillStateData(); return(skeletonData); }