public void Initialize(bool overwrite) { if (this.IsValid && !overwrite) { return; } // Make sure none of the stuff is null if (this.skeletonDataAsset == null) { return; } if (this.skeletonDataAsset.atlasAssets.Length > 0) { material = skeletonDataAsset.atlasAssets[0].materials[0]; } var skeletonData = this.skeletonDataAsset.GetSkeletonData(false); if (skeletonData == null) { return; } if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].materials.Length <= 0) { return; } this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData()); if (state == null) { Clear(); return; } this.skeleton = new Skeleton(skeletonData); this.spineMeshGenerator = new Spine.Unity.MeshGeneration.ArraysSimpleMeshGenerator(); // You can switch this out with any other implementer of Spine.Unity.MeshGeneration.ISimpleMeshGenerator this.spineMeshGenerator.PremultiplyVertexColors = true; // Set the initial Skin and Animation if (!string.IsNullOrEmpty(initialSkinName)) { skeleton.SetSkin(initialSkinName); } if (!string.IsNullOrEmpty(startingAnimation)) { state.SetAnimation(0, startingAnimation, startingLoop); } }
public void Initialize (bool overwrite) { if (this.IsValid && !overwrite) return; // Make sure none of the stuff is null if (this.skeletonDataAsset == null) return; var skeletonData = this.skeletonDataAsset.GetSkeletonData(false); if (skeletonData == null) return; if (skeletonDataAsset.atlasAssets.Length <= 0 || skeletonDataAsset.atlasAssets[0].materials.Length <= 0) return; this.state = new Spine.AnimationState(skeletonDataAsset.GetAnimationStateData()); if (state == null) { Clear(); return; } this.skeleton = new Skeleton(skeletonData); this.spineMeshGenerator = new Spine.Unity.MeshGeneration.ArraysSimpleMeshGenerator(); // You can switch this out with any other implementer of Spine.Unity.MeshGeneration.ISimpleMeshGenerator this.spineMeshGenerator.PremultiplyVertexColors = true; // Set the initial Skin and Animation if (!string.IsNullOrEmpty(initialSkinName)) skeleton.SetSkin(initialSkinName); if (!string.IsNullOrEmpty(startingAnimation)) state.SetAnimation(0, startingAnimation, startingLoop); }