private void Start()
                {
                    _spineAnimator = GetComponent <SpineAnimator>();

                    ISkeletonAnimation s = _spineAnimator.GetSkeletonAnimation() as ISkeletonAnimation;

                    if (s != null)
                    {
                        s.UpdateLocal += HandleUpdateLocal;
                    }

                    IAnimationStateComponent sa = _spineAnimator.GetSkeletonAnimation() as IAnimationStateComponent;

                    if (sa != null)
                    {
                        this._state = sa.AnimationState;
                    }

                    SetSourceBone(_sourceBoneName);

                    Skeleton skeleton = s.Skeleton;

                    _siblingBones.Clear();
                    foreach (string bn in _siblingBoneNames)
                    {
                        Bone b = skeleton.FindBone(bn);
                        if (b != null)
                        {
                            _siblingBones.Add(b);
                        }
                    }
                }
예제 #2
0
 private void ApplyInEditor()
 {
     for (int i = 0; i < _animationStates.Length; i++)
     {
         SpineAnimator spineAnimator = _trackBinding._renderer._animationSets[i]._animatior;
         spineAnimator.GetSkeletonAnimation().Skeleton.SetToSetupPose();
         _animationStates[i].Apply(spineAnimator.GetSkeletonAnimation().Skeleton);
     }
 }
예제 #3
0
                public override void ProcessFrame(Playable playable, FrameData info, object playerData)
                {
                    if (_trackBinding != null && _animationStates != null)
                    {
                        for (int i = 0; i < _animationStates.Length; i++)
                        {
                            Spine3DAnimationSet animationSet = _trackBinding._renderer._animationSets[i];
                            ApplyChannelsToState(animationSet, _animationStates[i]);
                        }
#if UNITY_EDITOR
                        if (!Application.isPlaying)
                        {
                            ApplyInEditor();
                        }
                        else
#endif
                        {
                            for (int i = 0; i < _animationStates.Length; i++)
                            {
                                SpineAnimator spineAnimator = _trackBinding._renderer._animationSets[i]._animatior;
                                _animationStates[i].Apply(spineAnimator.GetSkeletonAnimation().Skeleton);
                            }
                        }
                    }
                }
예제 #4
0
                public void SetTrackAsset(TrackAsset trackAsset, PlayableDirector playableDirector)
                {
                    _trackAsset   = trackAsset as Spine3DAnimatorTrack;
                    _director     = playableDirector;
                    _trackBinding = _director.GetGenericBinding(trackAsset) as Spine3DAnimator;

                    if (_trackBinding != null)
                    {
                        _animationStates = new AnimationState[_trackBinding._renderer._animationSets.Length];

                        for (int i = 0; i < _animationStates.Length; i++)
                        {
                            SpineAnimator spineAnimator = _trackBinding._renderer._animationSets[i]._animatior;
                            _animationStates[i] = new AnimationState(spineAnimator.GetSkeletonAnimation().SkeletonDataAsset.GetAnimationStateData());
                        }
                    }
                }
                public void SetSourceBone(string name)
                {
                    var skeleton = _spineAnimator.GetSkeletonAnimation().Skeleton;
                    int bi       = skeleton.FindBoneIndex(name);

                    if (bi >= 0)
                    {
                        this._boneIndex = bi;
                        this._bone      = skeleton.Bones.Items[bi];
                    }
                    else
                    {
                        Debug.Log("Bone named \"" + name + "\" could not be found.");
                        this._boneIndex = 0;
                        this._bone      = skeleton.RootBone;
                    }
                }