Exemple #1
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;
            }
        }
Exemple #2
0
    public override void ProcessFrame(Playable playable, FrameData info, object playerData)
    {
        skeletonComponent = playerData as SkeletonRenderer;

        if (skeletonComponent == null)
        {
            return;
        }

        var skeleton = skeletonComponent.Skeleton;

        if (!m_FirstFrameHappened)
        {
            defaultFlipX         = skeleton.flipX;
            defaultFlipY         = skeleton.flipY;
            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)
            {
                skeleton.flipX = input.flipX;
                skeleton.flipY = input.flipY;
                greatestWeight = inputWeight;
            }

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

        if (currentInputs != 1 && 1f - totalWeight > greatestWeight)
        {
            skeleton.flipX = defaultFlipX;
            skeleton.flipY = defaultFlipY;
        }
    }
 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;
         }
     }
 }