Beispiel #1
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            // Q: Does ProcessFrame come before or after MonoBehaviour.Update?
            //Debug.Log("MixerBehaviour ProcessFrame " + Time.frameCount);
            // A: MonoBehaviour.Update comes first. Then PlayableBehaviour.ProcessFrame.

            trackBindingPlayableHandle = playerData as SpinePlayableHandleBase;
            if (trackBindingPlayableHandle == null)
            {
                return;
            }

            // Ensure initialize all clipBehaviourData.
            if (!clipsInitialized)
            {
                var skeletonData = trackBindingPlayableHandle.SkeletonData;
                for (int i = 0, inputCount = playable.GetInputCount(); i < inputCount; i++)
                {
                    var inputPlayableClip = (ScriptPlayable <SpineAnimationBehaviour>)playable.GetInput(i);           // The clip. Returns a handle struct.
                    SpineAnimationBehaviour clipBehaviourData = inputPlayableClip.GetBehaviour();                     // the stateless data
                    clipBehaviourData.EnsureInitialize(skeletonData);
                }
                clipsInitialized = true;
            }

            trackBindingPlayableHandle.ProcessFrame(playable, info, this);

            if (Application.isPlaying)
            {
                trackBindingPlayableHandle.HandleEvents(eventBuffer);
                eventBuffer.Clear();
            }
        }
Beispiel #2
0
        public override void ProcessFrame(Playable playable, FrameData info, object playerData)
        {
            playableHandle = playerData as SpinePlayableHandleBase;

            if (playableHandle == null)
            {
                return;
            }

            var skeleton = playableHandle.Skeleton;

            if (!m_FirstFrameHappened)
            {
                originalScaleX       = skeleton.ScaleX;
                originalScaleY       = skeleton.ScaleY;
                baseScaleX           = Mathf.Abs(originalScaleX);
                baseScaleY           = Mathf.Abs(originalScaleY);
                m_FirstFrameHappened = true;
            }

            int inputCount = playable.GetInputCount();

            float totalWeight    = 0f;
            float greatestWeight = 0f;
            int   currentInputs  = 0;

            for (int i = 0; i < inputCount; i++)
            {
                float inputWeight = playable.GetInputWeight(i);
                ScriptPlayable <SpineSkeletonFlipBehaviour> inputPlayable = (ScriptPlayable <SpineSkeletonFlipBehaviour>)playable.GetInput(i);
                SpineSkeletonFlipBehaviour input = inputPlayable.GetBehaviour();

                totalWeight += inputWeight;

                if (inputWeight > greatestWeight)
                {
                    SetSkeletonScaleFromFlip(skeleton, input.flipX, input.flipY);
                    greatestWeight = inputWeight;
                }

                if (!Mathf.Approximately(inputWeight, 0f))
                {
                    currentInputs++;
                }
            }

            if (currentInputs != 1 && 1f - totalWeight > greatestWeight)
            {
                skeleton.ScaleX = originalScaleX;
                skeleton.ScaleY = originalScaleY;
            }
        }
 public override void ProcessFrame(Playable playable, FrameData info, object playerData)
 {
     this.playableHandle = playerData as SpinePlayableHandleBase;
     if (this.playableHandle != null)
     {
         Skeleton skeleton = this.playableHandle.Skeleton;
         if (!this.m_FirstFrameHappened)
         {
             this.defaultFlipX         = skeleton.flipX;
             this.defaultFlipY         = skeleton.flipY;
             this.m_FirstFrameHappened = true;
         }
         int   inputCount = playable.GetInputCount <Playable>();
         float num2       = 0f;
         float num3       = 0f;
         int   num4       = 0;
         for (int i = 0; i < inputCount; i++)
         {
             float inputWeight = playable.GetInputWeight <Playable>(i);
             SpineSkeletonFlipBehaviour behaviour = ((ScriptPlayable <SpineSkeletonFlipBehaviour>)playable.GetInput <Playable>(i)).GetBehaviour();
             num2 += inputWeight;
             if (inputWeight > num3)
             {
                 skeleton.flipX = behaviour.flipX;
                 skeleton.flipY = behaviour.flipY;
                 num3           = inputWeight;
             }
             if (!Mathf.Approximately(inputWeight, 0f))
             {
                 num4++;
             }
         }
         if ((num4 != 1) && ((1f - num2) > num3))
         {
             skeleton.flipX = this.defaultFlipX;
             skeleton.flipY = this.defaultFlipY;
         }
     }
 }
Beispiel #4
0
        public override void GatherProperties(PlayableDirector director, IPropertyCollector driver)
        {
#if UNITY_EDITOR
            SpinePlayableHandleBase trackBinding = director.GetGenericBinding(this) as SpinePlayableHandleBase;
            if (trackBinding == null)
            {
                return;
            }

            var serializedObject = new UnityEditor.SerializedObject(trackBinding);
            var iterator         = serializedObject.GetIterator();
            while (iterator.NextVisible(true))
            {
                if (iterator.hasVisibleChildren)
                {
                    continue;
                }

                driver.AddFromName <SpinePlayableHandleBase>(trackBinding.gameObject, iterator.propertyPath);
            }
#endif
            base.GatherProperties(director, driver);
        }