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.ArraysSimpleMeshGenerator();         // You can switch this out with any other implementer of ISpineMeshGenerator

        // Set the initial Skin and Animation
        if (!string.IsNullOrEmpty(initialSkinName))
        {
            skeleton.SetSkin(initialSkinName);
        }

        if (!string.IsNullOrEmpty(startingAnimation))
        {
            state.SetAnimation(0, startingAnimation, startingLoop);
        }
    }
Пример #2
0
	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.ArraysSimpleMeshGenerator(); // You can switch this out with any other implementer of ISpineMeshGenerator

		// Set the initial Skin and Animation
		if (!string.IsNullOrEmpty(initialSkinName))
			skeleton.SetSkin(initialSkinName);

		if (!string.IsNullOrEmpty(startingAnimation))
			state.SetAnimation(0, startingAnimation, startingLoop);
	}