Beispiel #1
0
        void TemplateFadeOut()
        {
            // Set Gradient to Fade In White
            Gradient g = new Gradient();

            GradientColorKey[] gck = new GradientColorKey[2];
            gck[0].color = Color.white;
            gck[0].time  = 0f;
            gck[1].color = Color.white;
            gck[1].time  = 1f;
            GradientAlphaKey[] gak = new GradientAlphaKey[2];
            gak[0].alpha = 1f;
            gak[0].time  = 0f;
            gak[1].alpha = 0f;
            gak[1].time  = 1f;
            g.SetKeys(gck, gak);
            colorOverLifeTime = g;


            sizeOverLifeTime    = AnimationCurve.Constant(0f, 1f, 1f);
            mixMode             = MixMode.Multiply;
            activationMode      = ActivationMode.Manual;
            enableRaycastTarget = false;

            onFinishedEvent = new UnityEvent();
            UnityEditor.Events.UnityEventTools.AddPersistentListener(onFinishedEvent, () => { gameObject.SetActive(false); });
        }
Beispiel #2
0
        /// <summary>
        /// Mix Sound sample of given <see cref="Chart"/>.
        /// Resulting a single <see cref="MixedSample"/> of prerendered the <see cref="Chart"/>.
        /// </summary>
        /// <param name="chart">a <see cref="Chart"/> instance that contain samples to be mixed and prerendered.</param>
        /// <param name="mode">Specifies sample mixing mode.</param>
        /// <param name="channelCount">The number of channels that will be used for prerendering the <see cref="Chart"/>.</param>
        /// <param name="sampleRate">The rate of sample that will be used for prerendering the <see cref="Chart"/>.</param>
        /// <returns>a Single <see cref="MixedSample"/> of prerendered given <see cref="Chart"/></returns>
        public static MixedSample Mix(Chart chart, MixMode mode = MixMode.Full, int channelCount = 2, int sampleRate = 44100)
        {
            int sampleCount = (sampleRate * channelCount);
            var samples     = new short[sampleCount * (int)chart.Duration.TotalSeconds];
            var events      = Array.ConvertAll(Array.FindAll(chart.Events, (ev) => ev is Event.Sound), ((ev) => ev as Event.Sound));

            foreach (var ev in events)
            {
                if (ev.Payload == null || ev.Signature == Event.SignatureType.Release || (mode == MixMode.BGM && ev.Channel != Event.ChannelType.BGM) || (mode == MixMode.Keysound && ev.Channel == Event.ChannelType.BGM))
                {
                    continue;
                }

                using (var stream = new MemoryStream(ev.Payload))
                    using (var decoder = SoundProcessorFactory.CreateDecoder(stream))
                    {
                        var info = decoder.SampleInfo;

                        var  keysound = new short[info.SampleCount];
                        long offset   = (long)(ev.Timestamp.TotalSeconds * sampleCount);
                        long read     = 0;

                        while ((read = decoder.Read(keysound, info.SampleCount)) > 0)
                        {
                            if (offset + read >= samples.Length)
                            {
                                int newSize = samples.Length;
                                while (newSize < offset + read)
                                {
                                    newSize += sampleRate * channelCount;
                                }

                                Array.Resize(ref samples, newSize);
                            }

                            for (int i = 0; i < read; i++)
                            {
                                int buffer = samples[offset + i] + keysound[i];
                                if (buffer > short.MaxValue)
                                {
                                    buffer = short.MaxValue;
                                }
                                else if (buffer < short.MinValue)
                                {
                                    buffer = short.MinValue;
                                }

                                samples[offset + i] = (short)buffer;
                            }

                            offset += read;
                        }
                    }
            }

            return(new MixedSample(samples, channelCount, sampleRate));
        }
        public void Play(int track, AudioSetting setting, PlayMode playMode, MixMode mixmode)
        {
            TryCreateTrack(track);

            Mixer <AudioTrack.AudioPlayer> mixer = AudioMixerFactory.CreateNullMixer();

            if (mixmode == MixMode.VolumeMix)
            {
                mixer = AudioMixerFactory.CreateVolumeMixer();
            }

            this.tracks[track].SetTrackMixer(mixer);
            this.tracks[track].Play(setting, playMode, true);
        }
Beispiel #4
0
 private MixMode GetMixMode(int layer, MixBlend layerBlendMode)
 {
     if (useCustomMixMode)
     {
         MixMode mode = layerMixModes[layer];
         // Note: at additive blending it makes no sense to use constant weight 1 at a fadeout anim add1 as
         // with override layers, so we use AlwaysMix instead to use the proper weights.
         // AlwaysMix leads to the expected result = lower_layer + lerp(add1, add2, transition_weight).
         if (layerBlendMode == MixBlend.Add && mode == MixMode.MixNext)
         {
             mode = MixMode.AlwaysMix;
             layerMixModes[layer] = mode;
         }
         return(mode);
     }
     else
     {
         return(layerBlendMode == MixBlend.Add ? MixMode.AlwaysMix : MixMode.MixNext);
     }
 }
Beispiel #5
0
        void TemplateFadeIn()
        {
            // Set Gradient to Fade In White
            Gradient g = new Gradient();

            GradientColorKey[] gck = new GradientColorKey[2];
            gck[0].color = Color.white;
            gck[0].time  = 0f;
            gck[1].color = Color.white;
            gck[1].time  = 1f;
            GradientAlphaKey[] gak = new GradientAlphaKey[2];
            gak[0].alpha = 0f;
            gak[0].time  = 0f;
            gak[1].alpha = 1f;
            gak[1].time  = 1f;
            g.SetKeys(gck, gak);
            colorOverLifeTime = g;

            sizeOverLifeTime    = AnimationCurve.Constant(0f, 1f, 1f);
            mixMode             = MixMode.Multiply;
            activationMode      = ActivationMode.OnStart;
            enableRaycastTarget = false;
        }
Beispiel #6
0
        void Update()
        {
            if (!valid)
            {
                return;
            }

            if (layerMixModes.Length < animator.layerCount)
            {
                System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
            }

            //skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.5).

            // Clear Previous
            if (autoReset)
            {
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    float layerWeight = animator.GetLayerWeight(layer);
                    if (layerWeight <= 0)
                    {
                        continue;
                    }

                    AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                    bool hasNext = nextStateInfo.fullPathHash != 0;
                    AnimatorClipInfo[] clipInfo     = animator.GetCurrentAnimatorClipInfo(layer);
                    AnimatorClipInfo[] nextClipInfo = animator.GetNextAnimatorClipInfo(layer);


                    for (int c = 0; c < clipInfo.Length; c++)
                    {
                        AnimatorClipInfo info = clipInfo[c];    float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        animationTable[NameHashCode(info.clip)].SetKeyedItemsToSetupPose(skeleton);
                    }
                    if (hasNext)
                    {
                        for (int c = 0; c < nextClipInfo.Length; c++)
                        {
                            AnimatorClipInfo info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable[NameHashCode(info.clip)].SetKeyedItemsToSetupPose(skeleton);
                        }
                    }
                }
            }


            // Apply
            for (int layer = 0, n = animator.layerCount; layer < n; layer++)
            {
                float             layerWeight   = (layer == 0) ? 1 : animator.GetLayerWeight(layer);
                AnimatorStateInfo stateInfo     = animator.GetCurrentAnimatorStateInfo(layer);
                AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                bool hasNext = nextStateInfo.fullPathHash != 0;
                AnimatorClipInfo[] clipInfo     = animator.GetCurrentAnimatorClipInfo(layer);
                AnimatorClipInfo[] nextClipInfo = animator.GetNextAnimatorClipInfo(layer);

                MixMode mode = layerMixModes[layer];
                if (mode == MixMode.AlwaysMix)
                {
                    // Always use Mix instead of Applying the first non-zero weighted clip.
                    for (int c = 0; c < clipInfo.Length; c++)
                    {
                        AnimatorClipInfo info = clipInfo[c];    float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop), stateInfo.loop, null, weight, false, false);
                    }
                    if (hasNext)
                    {
                        for (int c = 0; c < nextClipInfo.Length; c++)
                        {
                            AnimatorClipInfo info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, nextStateInfo.normalizedTime * info.clip.length, nextStateInfo.loop, null, weight, false, false);
                        }
                    }
                }
                else                     // case MixNext || SpineStyle
                                         // Apply first non-zero weighted clip
                {
                    int c = 0;
                    for (; c < clipInfo.Length; c++)
                    {
                        AnimatorClipInfo info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop), stateInfo.loop, null, 1f, false, false);
                        break;
                    }
                    // Mix the rest
                    for (; c < clipInfo.Length; c++)
                    {
                        AnimatorClipInfo info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop), stateInfo.loop, null, weight, false, false);
                    }

                    c = 0;
                    if (hasNext)
                    {
                        // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                        if (mode == MixMode.SpineStyle)
                        {
                            for (; c < nextClipInfo.Length; c++)
                            {
                                AnimatorClipInfo info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, nextStateInfo.normalizedTime * info.clip.length, nextStateInfo.loop, null, 1f, false, false);
                                break;
                            }
                        }
                        // Mix the rest
                        for (; c < nextClipInfo.Length; c++)
                        {
                            AnimatorClipInfo info = nextClipInfo[c];        float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, nextStateInfo.normalizedTime * info.clip.length, nextStateInfo.loop, null, weight, false, false);
                        }
                    }
                }
            }

            // UpdateWorldTransform and Bone Callbacks
            {
                if (_UpdateLocal != null)
                {
                    _UpdateLocal(this);
                }

                skeleton.UpdateWorldTransform();

                if (_UpdateWorld != null)
                {
                    _UpdateWorld(this);
                    skeleton.UpdateWorldTransform();
                }

                if (_UpdateComplete != null)
                {
                    _UpdateComplete(this);
                }
            }
        }
Beispiel #7
0
 public void SetBkMode(MixMode bkMode)
 {
     _currentState.BackgroundMode = bkMode;
 }
    void Update()
    {
        if (!valid)
        {
            return;
        }

        if (layerMixModes.Length != animator.layerCount)
        {
            System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
        }

        skeleton.Update(Time.deltaTime);

        //apply
        int   layerCount = animator.layerCount;
        float deltaTime  = Time.deltaTime;

        for (int i = 0; i < layerCount; i++)
        {
            float layerWeight = animator.GetLayerWeight(i);
            if (i == 0)
            {
                layerWeight = 1;
            }

            var stateInfo     = animator.GetCurrentAnimatorStateInfo(i);
            var nextStateInfo = animator.GetNextAnimatorStateInfo(i);

#if UNITY_5
            var clipInfo     = animator.GetCurrentAnimatorClipInfo(i);
            var nextClipInfo = animator.GetNextAnimatorClipInfo(i);
#else
            var clipInfo     = animator.GetCurrentAnimatorClipInfo(i);
            var nextClipInfo = animator.GetNextAnimatorClipInfo(i);
#endif
            MixMode mode = layerMixModes[i];

            if (mode == MixMode.AlwaysMix)
            {
                //always use Mix instead of Applying the first non-zero weighted clip
                foreach (var info in clipInfo)
                {
                    float weight = info.weight * layerWeight;
                    if (weight == 0)
                    {
                        continue;
                    }

                    float time = stateInfo.normalizedTime * info.clip.length;
                    animationTable[info.clip.name].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, null, weight);
                }

                foreach (var info in nextClipInfo)
                {
                    float weight = info.weight * layerWeight;
                    if (weight == 0)
                    {
                        continue;
                    }

                    float time = nextStateInfo.normalizedTime * info.clip.length;
                    animationTable[info.clip.name].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null, weight);
                }
            }
            else if (mode >= MixMode.MixNext)
            {
                //apply first non-zero weighted clip
                int c = 0;

                for (; c < clipInfo.Length; c++)
                {
                    var   info   = clipInfo[c];
                    float weight = info.weight * layerWeight;
                    if (weight == 0)
                    {
                        continue;
                    }

                    float time = stateInfo.normalizedTime * info.clip.length;
                    animationTable[info.clip.name].Apply(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, null);
                    break;
                }

                //mix the rest
                for (; c < clipInfo.Length; c++)
                {
                    var   info   = clipInfo[c];
                    float weight = info.weight * layerWeight;
                    if (weight == 0)
                    {
                        continue;
                    }

                    float time = stateInfo.normalizedTime * info.clip.length;
                    animationTable[info.clip.name].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, null, weight);
                }

                c = 0;

                //apply next clip directly instead of mixing (ie:  no crossfade, ignores mecanim transition weights)
                if (mode == MixMode.SpineStyle)
                {
                    for (; c < nextClipInfo.Length; c++)
                    {
                        var   info   = nextClipInfo[c];
                        float weight = info.weight * layerWeight;
                        if (weight == 0)
                        {
                            continue;
                        }

                        float time = nextStateInfo.normalizedTime * info.clip.length;
                        animationTable[info.clip.name].Apply(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null);
                        break;
                    }
                }

                //mix the rest
                for (; c < nextClipInfo.Length; c++)
                {
                    var   info   = nextClipInfo[c];
                    float weight = info.weight * layerWeight;
                    if (weight == 0)
                    {
                        continue;
                    }

                    float time = nextStateInfo.normalizedTime * info.clip.length;
                    animationTable[info.clip.name].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, null, weight);
                }
            }
        }

        if (_UpdateLocal != null)
        {
            _UpdateLocal(this);
        }

        skeleton.UpdateWorldTransform();

        if (_UpdateWorld != null)
        {
            _UpdateWorld(this);
            skeleton.UpdateWorldTransform();
        }

        if (_UpdateComplete != null)
        {
            _UpdateComplete(this);
        }
    }
Beispiel #9
0
 public override void Read(BinaryReader reader)
 {
     this.Mode = (MixMode)reader.ReadUInt16();
 }
            public void Apply(Skeleton skeleton)
            {
                if (layerMixModes.Length < animator.layerCount)
                {
                    System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
                    layerMixModes[animator.layerCount - 1] = MixMode.MixNext;
                }

                        #if UNITY_EDITOR
                if (!Application.isPlaying)
                {
                    GetLayerBlendModes();
                }
                        #endif
                InitClipInfosForLayers();
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    GetStateUpdatesFromAnimator(layer);
                }

                //skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.6).

                // Clear Previous
                if (autoReset)
                {
                    var previousAnimations = this.previousAnimations;
                    for (int i = 0, n = previousAnimations.Count; i < n; i++)
                    {
                        previousAnimations[i].SetKeyedItemsToSetupPose(skeleton);
                    }

                    previousAnimations.Clear();
                    for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                    {
                        float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);                         // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
                        if (layerWeight <= 0)
                        {
                            continue;
                        }

                        AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                        bool hasNext = nextStateInfo.fullPathHash != 0;

                        int clipInfoCount, nextClipInfoCount, interruptingClipInfoCount;
                        IList <AnimatorClipInfo> clipInfo, nextClipInfo, interruptingClipInfo;
                        bool isInterruptionActive, shallInterpolateWeightTo1;
                        GetAnimatorClipInfos(layer, out isInterruptionActive, out clipInfoCount, out nextClipInfoCount, out interruptingClipInfoCount,
                                             out clipInfo, out nextClipInfo, out interruptingClipInfo, out shallInterpolateWeightTo1);

                        for (int c = 0; c < clipInfoCount; c++)
                        {
                            var   info   = clipInfo[c];
                            float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            previousAnimations.Add(GetAnimation(info.clip));
                        }

                        if (hasNext)
                        {
                            for (int c = 0; c < nextClipInfoCount; c++)
                            {
                                var   info   = nextClipInfo[c];
                                float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                previousAnimations.Add(GetAnimation(info.clip));
                            }
                        }

                        if (isInterruptionActive)
                        {
                            for (int c = 0; c < interruptingClipInfoCount; c++)
                            {
                                var   info       = interruptingClipInfo[c];
                                float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
                                float weight     = clipWeight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                previousAnimations.Add(GetAnimation(info.clip));
                            }
                        }
                    }
                }

                // Apply
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);                     // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.

                    bool isInterruptionActive;
                    AnimatorStateInfo stateInfo;
                    AnimatorStateInfo nextStateInfo;
                    AnimatorStateInfo interruptingStateInfo;
                    float             interruptingClipTimeAddition;
                    GetAnimatorStateInfos(layer, out isInterruptionActive, out stateInfo, out nextStateInfo, out interruptingStateInfo, out interruptingClipTimeAddition);

                    bool hasNext = nextStateInfo.fullPathHash != 0;

                    int clipInfoCount, nextClipInfoCount, interruptingClipInfoCount;
                    IList <AnimatorClipInfo> clipInfo, nextClipInfo, interruptingClipInfo;
                    bool shallInterpolateWeightTo1;
                    GetAnimatorClipInfos(layer, out isInterruptionActive, out clipInfoCount, out nextClipInfoCount, out interruptingClipInfoCount,
                                         out clipInfo, out nextClipInfo, out interruptingClipInfo, out shallInterpolateWeightTo1);

                    MixMode  mode           = layerMixModes[layer];
                    MixBlend layerBlendMode = (layer < layerBlendModes.Length) ? layerBlendModes[layer] : MixBlend.Replace;
                    if (mode == MixMode.AlwaysMix)
                    {
                        // Always use Mix instead of Applying the first non-zero weighted clip.
                        for (int c = 0; c < clipInfoCount; c++)
                        {
                            var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
                        }
                        if (hasNext)
                        {
                            for (int c = 0; c < nextClipInfoCount; c++)
                            {
                                var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
                            }
                        }
                        if (isInterruptionActive)
                        {
                            for (int c = 0; c < interruptingClipInfoCount; c++)
                            {
                                var   info       = interruptingClipInfo[c];
                                float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
                                float weight     = clipWeight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0),
                                                              interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
                            }
                        }
                    }
                    else                         // case MixNext || Hard
                                                 // Apply first non-zero weighted clip
                    {
                        int c = 0;
                        for (; c < clipInfoCount; c++)
                        {
                            var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
                            break;
                        }
                        // Mix the rest
                        for (; c < clipInfoCount; c++)
                        {
                            var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
                        }

                        c = 0;
                        if (hasNext)
                        {
                            // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                            if (mode == MixMode.Hard)
                            {
                                for (; c < nextClipInfoCount; c++)
                                {
                                    var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                    {
                                        continue;
                                    }
                                    GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
                                    break;
                                }
                            }
                            // Mix the rest
                            for (; c < nextClipInfoCount; c++)
                            {
                                var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
                            }
                        }

                        c = 0;
                        if (isInterruptionActive)
                        {
                            // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                            if (mode == MixMode.Hard)
                            {
                                for (; c < interruptingClipInfoCount; c++)
                                {
                                    var   info       = interruptingClipInfo[c];
                                    float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
                                    float weight     = clipWeight * layerWeight; if (weight == 0)
                                    {
                                        continue;
                                    }
                                    GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, 1f, layerBlendMode, MixDirection.In);
                                    break;
                                }
                            }
                            // Mix the rest
                            for (; c < interruptingClipInfoCount; c++)
                            {
                                var   info       = interruptingClipInfo[c];
                                float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
                                float weight     = clipWeight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                GetAnimation(info.clip).Apply(skeleton, 0, AnimationTime(interruptingStateInfo.normalizedTime + interruptingClipTimeAddition, info.clip.length, interruptingStateInfo.speed < 0), interruptingStateInfo.loop, null, weight, layerBlendMode, MixDirection.In);
                            }
                        }
                    }
                }
            }
Beispiel #11
0
            public void Apply(Skeleton skeleton)
            {
                if (layerMixModes.Length < animator.layerCount)
                {
                    System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
                }

                //skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.6).

                // Clear Previous
                if (autoReset)
                {
                    var previousAnimations = this.previousAnimations;
                    for (int i = 0, n = previousAnimations.Count; i < n; i++)
                    {
                        previousAnimations[i].SetKeyedItemsToSetupPose(skeleton);
                    }

                    previousAnimations.Clear();
                    for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                    {
                        float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);                         // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
                        if (layerWeight <= 0)
                        {
                            continue;
                        }

                        AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                        bool hasNext = nextStateInfo.fullPathHash != 0;

                        int clipInfoCount, nextClipInfoCount;
                        IList <AnimatorClipInfo> clipInfo, nextClipInfo;
                        GetAnimatorClipInfos(layer, out clipInfoCount, out nextClipInfoCount, out clipInfo, out nextClipInfo);

                        for (int c = 0; c < clipInfoCount; c++)
                        {
                            var   info   = clipInfo[c];
                            float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            previousAnimations.Add(animationTable[NameHashCode(info.clip)]);
                        }

                        if (hasNext)
                        {
                            for (int c = 0; c < nextClipInfoCount; c++)
                            {
                                var   info   = nextClipInfo[c];
                                float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                previousAnimations.Add(animationTable[NameHashCode(info.clip)]);
                            }
                        }
                    }
                }

                // Apply
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    float             layerWeight   = (layer == 0) ? 1 : animator.GetLayerWeight(layer);       // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
                    AnimatorStateInfo stateInfo     = animator.GetCurrentAnimatorStateInfo(layer);
                    AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                    bool hasNext = nextStateInfo.fullPathHash != 0;

                    int clipInfoCount, nextClipInfoCount;
                    IList <AnimatorClipInfo> clipInfo, nextClipInfo;
                    GetAnimatorClipInfos(layer, out clipInfoCount, out nextClipInfoCount, out clipInfo, out nextClipInfo);

                    MixMode mode = layerMixModes[layer];
                    if (mode == MixMode.AlwaysMix)
                    {
                        // Always use Mix instead of Applying the first non-zero weighted clip.
                        for (int c = 0; c < clipInfoCount; c++)
                        {
                            var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
                        }
                        if (hasNext)
                        {
                            for (int c = 0; c < nextClipInfoCount; c++)
                            {
                                var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
                            }
                        }
                    }
                    else                         // case MixNext || SpineStyle
                                                 // Apply first non-zero weighted clip
                    {
                        int c = 0;
                        for (; c < clipInfoCount; c++)
                        {
                            var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
                            break;
                        }
                        // Mix the rest
                        for (; c < clipInfoCount; c++)
                        {
                            var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
                        }

                        c = 0;
                        if (hasNext)
                        {
                            // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                            if (mode == MixMode.SpineStyle)
                            {
                                for (; c < nextClipInfoCount; c++)
                                {
                                    var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                    {
                                        continue;
                                    }
                                    animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
                                    break;
                                }
                            }
                            // Mix the rest
                            for (; c < nextClipInfoCount; c++)
                            {
                                var info = nextClipInfo[c];     float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                animationTable[NameHashCode(info.clip)].Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, MixPose.Current, MixDirection.In);
                            }
                        }
                    }
                }
            }
Beispiel #12
0
        public void Update()
        {
            if (!valid)
            {
                return;
            }

            if (layerMixModes.Length < animator.layerCount)
            {
                System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
            }

            //skeleton.Update(Time.deltaTime); // Doesn't actually do anything, currently. (Spine 3.5).
            Spine.Animation spineAnimation;

            // Clear Previous
            if (autoReset)
            {
                var previousAnimations = this.previousAnimations;
                for (int i = 0, n = previousAnimations.Count; i < n; i++)
                {
                    previousAnimations[i].SetKeyedItemsToSetupPose(skeleton);
                }

                previousAnimations.Clear();
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);                     // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
                    if (layerWeight <= 0)
                    {
                        continue;
                    }

                    AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                    bool hasNext = nextStateInfo.fullPathHash != 0;
                    AnimatorClipInfo[] clipInfo     = animator.GetCurrentAnimatorClipInfo(layer);
                    AnimatorClipInfo[] nextClipInfo = animator.GetNextAnimatorClipInfo(layer);

                    for (int c = 0; c < clipInfo.Length; c++)
                    {
                        var   info   = clipInfo[c];
                        float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
                        if (spineAnimation != null)
                        {
                            previousAnimations.Add(spineAnimation);
                        }
                    }
                    if (hasNext)
                    {
                        for (int c = 0; c < nextClipInfo.Length; c++)
                        {
                            var   info   = nextClipInfo[c];
                            float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation);
                            if (spineAnimation != null)
                            {
                                previousAnimations.Add(spineAnimation);
                            }
                        }
                    }
                }
            }

            // Apply
            for (int layer = 0, n = animator.layerCount; layer < n; layer++)
            {
                float             layerWeight   = (layer == 0) ? 1 : animator.GetLayerWeight(layer);   // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
                AnimatorStateInfo stateInfo     = animator.GetCurrentAnimatorStateInfo(layer);
                AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                bool hasNext = nextStateInfo.fullPathHash != 0;
                AnimatorClipInfo[] clipInfo     = animator.GetCurrentAnimatorClipInfo(layer);
                AnimatorClipInfo[] nextClipInfo = animator.GetNextAnimatorClipInfo(layer);
                //UNITY 4
                //bool hasNext = nextStateInfo.nameHash != 0;
                //var clipInfo = animator.GetCurrentAnimationClipState(i);
                //var nextClipInfo = animator.GetNextAnimationClipState(i);

                MixMode mode = layerMixModes[layer];
                if (mode == MixMode.AlwaysMix)
                {
                    // Always use Mix instead of Applying the first non-zero weighted clip.
                    for (int c = 0; c < clipInfo.Length; c++)
                    {
                        var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        if (animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation))
                        {
                            spineAnimation.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, false, false);
                        }
                        else if (logErrors)
                        {
                            SkeletonAnimator.LogMissingAnimationClip(this, info.clip.name);
                        }
                    }
                    if (hasNext)
                    {
                        for (int c = 0; c < nextClipInfo.Length; c++)
                        {
                            var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            if (animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation))
                            {
                                spineAnimation.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, false, false);
                            }
                            else if (logErrors)
                            {
                                SkeletonAnimator.LogMissingAnimationClip(this, info.clip.name);
                            }
                        }
                    }
                }
                else                     // case MixNext || SpineStyle
                                         // Apply first non-zero weighted clip
                {
                    int c = 0;
                    for (; c < clipInfo.Length; c++)
                    {
                        var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        if (animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation))
                        {
                            spineAnimation.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, 1f, false, false);
                        }
                        else if (logErrors)
                        {
                            SkeletonAnimator.LogMissingAnimationClip(this, info.clip.name);
                        }
                        break;
                    }
                    // Mix the rest
                    for (; c < clipInfo.Length; c++)
                    {
                        var info = clipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                        {
                            continue;
                        }
                        if (animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation))
                        {
                            spineAnimation.Apply(skeleton, 0, AnimationTime(stateInfo.normalizedTime, info.clip.length, stateInfo.loop, stateInfo.speed < 0), stateInfo.loop, null, weight, false, false);
                        }
                        else if (logErrors)
                        {
                            SkeletonAnimator.LogMissingAnimationClip(this, info.clip.name);
                        }
                    }

                    c = 0;
                    if (hasNext)
                    {
                        // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                        if (mode == MixMode.SpineStyle)
                        {
                            for (; c < nextClipInfo.Length; c++)
                            {
                                var info = nextClipInfo[c]; float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                if (animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation))
                                {
                                    spineAnimation.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, 1f, false, false);
                                }
                                else if (logErrors)
                                {
                                    SkeletonAnimator.LogMissingAnimationClip(this, info.clip.name);
                                }
                                break;
                            }
                        }
                        // Mix the rest
                        for (; c < nextClipInfo.Length; c++)
                        {
                            var info = nextClipInfo[c];     float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            if (animationTable.TryGetValue(NameHashCode(info.clip), out spineAnimation))
                            {
                                spineAnimation.Apply(skeleton, 0, AnimationTime(nextStateInfo.normalizedTime, info.clip.length, nextStateInfo.speed < 0), nextStateInfo.loop, null, weight, false, false);
                            }
                            else if (logErrors)
                            {
                                SkeletonAnimator.LogMissingAnimationClip(this, info.clip.name);
                            }
                        }
                    }
                }
            }

            // UpdateWorldTransform and Bone Callbacks
            {
                if (_UpdateLocal != null)
                {
                    _UpdateLocal(this);
                }

                skeleton.UpdateWorldTransform();

                if (_UpdateWorld != null)
                {
                    _UpdateWorld(this);
                    skeleton.UpdateWorldTransform();
                }

                if (_UpdateComplete != null)
                {
                    _UpdateComplete(this);
                }
            }
        }
Beispiel #13
0
        private void Update()
        {
            if (!this.valid)
            {
                return;
            }
            if (this.layerMixModes.Length != this.animator.layerCount)
            {
                Array.Resize(ref this.layerMixModes, this.animator.layerCount);
            }
            float num = Time.time - this.lastTime;

            this.skeleton.Update(Time.deltaTime);
            int layerCount = this.animator.layerCount;

            for (int i = 0; i < layerCount; i++)
            {
                float num2 = this.animator.GetLayerWeight(i);
                if (i == 0)
                {
                    num2 = 1f;
                }
                AnimatorStateInfo  currentAnimatorStateInfo = this.animator.GetCurrentAnimatorStateInfo(i);
                AnimatorStateInfo  nextAnimatorStateInfo    = this.animator.GetNextAnimatorStateInfo(i);
                AnimatorClipInfo[] currentAnimatorClipInfo  = this.animator.GetCurrentAnimatorClipInfo(i);
                AnimatorClipInfo[] nextAnimatorClipInfo     = this.animator.GetNextAnimatorClipInfo(i);
                MixMode            mixMode = this.layerMixModes[i];
                if (mixMode == SkeletonAnimator.MixMode.AlwaysMix)
                {
                    foreach (AnimatorClipInfo animatorClipInfo in currentAnimatorClipInfo)
                    {
                        float num3 = animatorClipInfo.weight * num2;
                        if (num3 != 0f)
                        {
                            float num4 = currentAnimatorStateInfo.normalizedTime * animatorClipInfo.clip.length;
                            this.animationTable[this.GetAnimationClipNameHashCode(animatorClipInfo.clip)].Mix(this.skeleton, Mathf.Max(0f, num4 - num), num4, currentAnimatorStateInfo.loop, this.events, num3);
                        }
                    }
                    if (nextAnimatorStateInfo.nameHash != 0)
                    {
                        foreach (AnimatorClipInfo animatorClipInfo2 in nextAnimatorClipInfo)
                        {
                            float num5 = animatorClipInfo2.weight * num2;
                            if (num5 != 0f)
                            {
                                float num6 = nextAnimatorStateInfo.normalizedTime * animatorClipInfo2.clip.length;
                                this.animationTable[this.GetAnimationClipNameHashCode(animatorClipInfo2.clip)].Mix(this.skeleton, Mathf.Max(0f, num6 - num), num6, nextAnimatorStateInfo.loop, this.events, num5);
                            }
                        }
                    }
                }
                else if (mixMode >= SkeletonAnimator.MixMode.MixNext)
                {
                    int l;
                    for (l = 0; l < currentAnimatorClipInfo.Length; l++)
                    {
                        AnimatorClipInfo animatorClipInfo3 = currentAnimatorClipInfo[l];
                        float            num7 = animatorClipInfo3.weight * num2;
                        if (num7 != 0f)
                        {
                            float num8 = currentAnimatorStateInfo.normalizedTime * animatorClipInfo3.clip.length;
                            this.animationTable[this.GetAnimationClipNameHashCode(animatorClipInfo3.clip)].Apply(this.skeleton, Mathf.Max(0f, num8 - num), num8, currentAnimatorStateInfo.loop, this.events);
                            break;
                        }
                    }
                    while (l < currentAnimatorClipInfo.Length)
                    {
                        AnimatorClipInfo animatorClipInfo4 = currentAnimatorClipInfo[l];
                        float            num9 = animatorClipInfo4.weight * num2;
                        if (num9 != 0f)
                        {
                            float num10 = currentAnimatorStateInfo.normalizedTime * animatorClipInfo4.clip.length;
                            this.animationTable[this.GetAnimationClipNameHashCode(animatorClipInfo4.clip)].Mix(this.skeleton, Mathf.Max(0f, num10 - num), num10, currentAnimatorStateInfo.loop, this.events, num9);
                        }
                        l++;
                    }
                    l = 0;
                    if (nextAnimatorStateInfo.nameHash != 0)
                    {
                        if (mixMode == SkeletonAnimator.MixMode.SpineStyle)
                        {
                            while (l < nextAnimatorClipInfo.Length)
                            {
                                AnimatorClipInfo animatorClipInfo5 = nextAnimatorClipInfo[l];
                                float            num11             = animatorClipInfo5.weight * num2;
                                if (num11 != 0f)
                                {
                                    float num12 = nextAnimatorStateInfo.normalizedTime * animatorClipInfo5.clip.length;
                                    this.animationTable[this.GetAnimationClipNameHashCode(animatorClipInfo5.clip)].Apply(this.skeleton, Mathf.Max(0f, num12 - num), num12, nextAnimatorStateInfo.loop, this.events);
                                    break;
                                }
                                l++;
                            }
                        }
                        while (l < nextAnimatorClipInfo.Length)
                        {
                            AnimatorClipInfo animatorClipInfo6 = nextAnimatorClipInfo[l];
                            float            num13             = animatorClipInfo6.weight * num2;
                            if (num13 != 0f)
                            {
                                float num14 = nextAnimatorStateInfo.normalizedTime * animatorClipInfo6.clip.length;
                                this.animationTable[this.GetAnimationClipNameHashCode(animatorClipInfo6.clip)].Mix(this.skeleton, Mathf.Max(0f, num14 - num), num14, nextAnimatorStateInfo.loop, this.events, num13);
                            }
                            l++;
                        }
                    }
                }
            }
            if (this._UpdateLocal != null)
            {
                this._UpdateLocal(this);
            }
            this.skeleton.UpdateWorldTransform();
            if (this._UpdateWorld != null)
            {
                this._UpdateWorld(this);
                this.skeleton.UpdateWorldTransform();
            }
            if (this._UpdateComplete != null)
            {
                this._UpdateComplete(this);
            }
            this.lastTime = Time.time;
        }
Beispiel #14
0
            public void Apply(Skeleton skeleton)
            {
                        #if UNITY_EDITOR
                if (!Application.isPlaying)
                {
                    GetLayerBlendModes();
                }
                        #endif

                if (layerMixModes.Length < animator.layerCount)
                {
                    int oldSize = layerMixModes.Length;
                    System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
                    for (int layer = oldSize; layer < animator.layerCount; ++layer)
                    {
                        bool isAdditiveLayer = false;
                        if (layer < layerBlendModes.Length)
                        {
                            isAdditiveLayer = layerBlendModes[layer] == MixBlend.Add;
                        }
                        layerMixModes[layer] = isAdditiveLayer ? MixMode.AlwaysMix : MixMode.MixNext;
                    }
                }

                InitClipInfosForLayers();
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    GetStateUpdatesFromAnimator(layer);
                }

                // Clear Previous
                if (autoReset)
                {
                    var previousAnimations = this.previousAnimations;
                    for (int i = 0, n = previousAnimations.Count; i < n; i++)
                    {
                        previousAnimations[i].SetKeyedItemsToSetupPose(skeleton);
                    }

                    previousAnimations.Clear();
                    for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                    {
                        float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);                         // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.
                        if (layerWeight <= 0)
                        {
                            continue;
                        }

                        AnimatorStateInfo nextStateInfo = animator.GetNextAnimatorStateInfo(layer);

                        bool hasNext = nextStateInfo.fullPathHash != 0;

                        int clipInfoCount, nextClipInfoCount, interruptingClipInfoCount;
                        IList <AnimatorClipInfo> clipInfo, nextClipInfo, interruptingClipInfo;
                        bool isInterruptionActive, shallInterpolateWeightTo1;
                        GetAnimatorClipInfos(layer, out isInterruptionActive, out clipInfoCount, out nextClipInfoCount, out interruptingClipInfoCount,
                                             out clipInfo, out nextClipInfo, out interruptingClipInfo, out shallInterpolateWeightTo1);

                        for (int c = 0; c < clipInfoCount; c++)
                        {
                            var   info   = clipInfo[c];
                            float weight = info.weight * layerWeight; if (weight == 0)
                            {
                                continue;
                            }
                            var clip = GetAnimation(info.clip);
                            if (clip != null)
                            {
                                previousAnimations.Add(clip);
                            }
                        }

                        if (hasNext)
                        {
                            for (int c = 0; c < nextClipInfoCount; c++)
                            {
                                var   info   = nextClipInfo[c];
                                float weight = info.weight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                var clip = GetAnimation(info.clip);
                                if (clip != null)
                                {
                                    previousAnimations.Add(clip);
                                }
                            }
                        }

                        if (isInterruptionActive)
                        {
                            for (int c = 0; c < interruptingClipInfoCount; c++)
                            {
                                var   info       = interruptingClipInfo[c];
                                float clipWeight = shallInterpolateWeightTo1 ? (info.weight + 1.0f) * 0.5f : info.weight;
                                float weight     = clipWeight * layerWeight; if (weight == 0)
                                {
                                    continue;
                                }
                                var clip = GetAnimation(info.clip);
                                if (clip != null)
                                {
                                    previousAnimations.Add(clip);
                                }
                            }
                        }
                    }
                }

                // Apply
                for (int layer = 0, n = animator.layerCount; layer < n; layer++)
                {
                    float layerWeight = (layer == 0) ? 1 : animator.GetLayerWeight(layer);                     // Animator.GetLayerWeight always returns 0 on the first layer. Should be interpreted as 1.

                    bool isInterruptionActive;
                    AnimatorStateInfo stateInfo;
                    AnimatorStateInfo nextStateInfo;
                    AnimatorStateInfo interruptingStateInfo;
                    float             interruptingClipTimeAddition;
                    GetAnimatorStateInfos(layer, out isInterruptionActive, out stateInfo, out nextStateInfo, out interruptingStateInfo, out interruptingClipTimeAddition);

                    bool hasNext = nextStateInfo.fullPathHash != 0;

                    int clipInfoCount, nextClipInfoCount, interruptingClipInfoCount;
                    IList <AnimatorClipInfo> clipInfo, nextClipInfo, interruptingClipInfo;
                    bool interpolateWeightTo1;
                    GetAnimatorClipInfos(layer, out isInterruptionActive, out clipInfoCount, out nextClipInfoCount, out interruptingClipInfoCount,
                                         out clipInfo, out nextClipInfo, out interruptingClipInfo, out interpolateWeightTo1);

                    MixBlend layerBlendMode = (layer < layerBlendModes.Length) ? layerBlendModes[layer] : MixBlend.Replace;
                    MixMode  mode           = GetMixMode(layer, layerBlendMode);
                    if (mode == MixMode.AlwaysMix)
                    {
                        // Always use Mix instead of Applying the first non-zero weighted clip.
                        for (int c = 0; c < clipInfoCount; c++)
                        {
                            ApplyAnimation(skeleton, clipInfo[c], stateInfo, layer, layerWeight, layerBlendMode);
                        }
                        if (hasNext)
                        {
                            for (int c = 0; c < nextClipInfoCount; c++)
                            {
                                ApplyAnimation(skeleton, nextClipInfo[c], nextStateInfo, layer, layerWeight, layerBlendMode);
                            }
                        }
                        if (isInterruptionActive)
                        {
                            for (int c = 0; c < interruptingClipInfoCount; c++)
                            {
                                ApplyInterruptionAnimation(skeleton, interpolateWeightTo1,
                                                           interruptingClipInfo[c], interruptingStateInfo,
                                                           layer, layerWeight, layerBlendMode, interruptingClipTimeAddition);
                            }
                        }
                    }
                    else                         // case MixNext || Hard
                                                 // Apply first non-zero weighted clip
                    {
                        int c = 0;
                        for (; c < clipInfoCount; c++)
                        {
                            if (!ApplyAnimation(skeleton, clipInfo[c], stateInfo, layer, layerWeight, layerBlendMode, useClipWeight1:true))
                            {
                                continue;
                            }
                            ++c; break;
                        }
                        // Mix the rest
                        for (; c < clipInfoCount; c++)
                        {
                            ApplyAnimation(skeleton, clipInfo[c], stateInfo, layer, layerWeight, layerBlendMode);
                        }

                        c = 0;
                        if (hasNext)
                        {
                            // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                            if (mode == MixMode.Hard)
                            {
                                for (; c < nextClipInfoCount; c++)
                                {
                                    if (!ApplyAnimation(skeleton, nextClipInfo[c], nextStateInfo, layer, layerWeight, layerBlendMode, useClipWeight1:true))
                                    {
                                        continue;
                                    }
                                    ++c; break;
                                }
                            }
                            // Mix the rest
                            for (; c < nextClipInfoCount; c++)
                            {
                                if (!ApplyAnimation(skeleton, nextClipInfo[c], nextStateInfo, layer, layerWeight, layerBlendMode))
                                {
                                    continue;
                                }
                            }
                        }

                        c = 0;
                        if (isInterruptionActive)
                        {
                            // Apply next clip directly instead of mixing (ie: no crossfade, ignores mecanim transition weights)
                            if (mode == MixMode.Hard)
                            {
                                for (; c < interruptingClipInfoCount; c++)
                                {
                                    if (ApplyInterruptionAnimation(skeleton, interpolateWeightTo1,
                                                                   interruptingClipInfo[c], interruptingStateInfo,
                                                                   layer, layerWeight, layerBlendMode, interruptingClipTimeAddition, useClipWeight1:true))
                                    {
                                        ++c; break;
                                    }
                                }
                            }
                            // Mix the rest
                            for (; c < interruptingClipInfoCount; c++)
                            {
                                ApplyInterruptionAnimation(skeleton, interpolateWeightTo1,
                                                           interruptingClipInfo[c], interruptingStateInfo,
                                                           layer, layerWeight, layerBlendMode, interruptingClipTimeAddition);
                            }
                        }
                    }
                }
            }
Beispiel #15
0
 /// <summary>
 /// 以(0,0)为轴点绘制Texture2D
 /// </summary>
 /// <param name="texture">目标Texture2D</param>
 /// <param name="transform">变换矩阵</param>
 /// <param name="overlayColor">要叠加的颜色</param>
 /// <param name="mode">图像混合模式</param>
 /// <returns></returns>
 public Texture2DCombiner DrawTexture(Texture2D texture, Matrix4x4 transform, Color overlayColor, MixMode mode = MixMode.Overlay)
 {
     return(DrawTexture(texture, transform, overlayColor, Vector2Int.zero, mode));
 }
Beispiel #16
0
 /// <summary>
 /// 不叠加颜色下绘制Texture2D
 /// </summary>
 /// <param name="texture">目标Texture2D</param>
 /// <param name="transform">变换矩阵</param>
 /// <param name="pivot">变换轴点</param>
 /// <param name="mode">图像混合模式</param>
 /// <returns></returns>
 public Texture2DCombiner DrawTexture(Texture2D texture, Matrix4x4 transform, Vector2 pivot, MixMode mode = MixMode.Overlay)
 {
     return(DrawTexture(texture, transform, Color.white, pivot, mode));
 }
Beispiel #17
0
        /// <summary>
        /// 绘制Texture2D
        /// </summary>
        /// <param name="texture">目标Texture2D</param>
        /// <param name="transform">变换矩阵</param>
        /// <param name="overlayColor">要叠加的颜色</param>
        /// <param name="pivot">变换轴点</param>
        /// <param name="mode">图像混合模式</param>
        /// <returns></returns>
        public Texture2DCombiner DrawTexture(Texture2D texture, Matrix4x4 transform, Color overlayColor, Vector2 pivot, MixMode mode = MixMode.Overlay)
        {
            var width  = texture.width;
            var height = texture.height;

            PrepareTransform(ref transform, in pivot, in width, in height, out var area);
            if (_renderCanvas == null)
            {
                var pixels       = texture.GetPixels();
                var canvasPixels = _canvas.GetPixels(area.x, area.y, area.width, area.height);
                var areaX        = area.xMax;
                var areaY        = area.yMax;
                for (var i = area.y - 1; ++i < areaY;)
                {
                    for (var j = area.x - 1; ++j < areaX;)
                    {
                        var position = (Vector2)transform.MultiplyPoint(new Vector2(j, i));
                        if (!position.x.InRange(0, width) || !position.y.InRange(0, height))
                        {
                            continue;
                        }
                        var canvasPixelIndex = j - area.x + (i - area.y) * area.width;
                        var origin           = canvasPixels[canvasPixelIndex];
                        var target           = BilinearInterpolation(position, pixels, width) * overlayColor;
                        canvasPixels[canvasPixelIndex] = MixColor(in origin, in target, mode);
                    }
                }
                _canvas.SetPixels(area.x, area.y, area.width, area.height, canvasPixels);
            }
            else
            {
                var kernel = GetKernel(mode);
                _shader.SetVector(ShaderSizeName, new Vector4(area.x, area.y, width, height));
                _shader.SetTexture(kernel, ShaderSourceName, texture);
                _shader.SetVector(ShaderColorName, overlayColor);
                _shader.SetMatrix(ShaderTransformName, transform);
                var currentTexture = _renderCanvas.Active();
                _shader.Dispatch(kernel, Mathf.CeilToInt(area.width / 24.0F), Mathf.CeilToInt(area.height / 24.0F), 1);
                RenderTexture.active = currentTexture;
            }
            return(this);
        }
Beispiel #18
0
        void Update()
        {
            if (!valid)
            {
                return;
            }

            if (cpuOptimizationLevel != 0)
            {
                skipFramesUpdate--;
                if (skipFramesUpdate > 0)
                {
                    return;
                }
                skipFramesUpdate = cpuOptimizationLevel + UnityEngine.Random.Range(0, cpuOptimizationLevel);
            }

            if (layerMixModes.Length != animator.layerCount)
            {
                System.Array.Resize <MixMode>(ref layerMixModes, animator.layerCount);
            }
            float deltaTime = Time.time - lastTime;

            skeleton.Update(Time.deltaTime);

            //apply
            int layerCount = animator.layerCount;

            for (int i = 0; i < layerCount; i++)
            {
                float layerWeight = animator.GetLayerWeight(i);
                if (i == 0)
                {
                    layerWeight = 1;
                }

                var stateInfo     = animator.GetCurrentAnimatorStateInfo(i);
                var nextStateInfo = animator.GetNextAnimatorStateInfo(i);

                                #if UNITY_5
                var clipInfo     = animator.GetCurrentAnimatorClipInfo(i);
                var nextClipInfo = animator.GetNextAnimatorClipInfo(i);
                                #else
                var clipInfo     = animator.GetCurrentAnimationClipState(i);
                var nextClipInfo = animator.GetNextAnimationClipState(i);
                                #endif
                MixMode mode = layerMixModes[i];

                if (mode == MixMode.AlwaysMix)
                {
                    //always use Mix instead of Applying the first non-zero weighted clip
                    for (int c = 0; c < clipInfo.Length; c++)
                    {
                        var   info   = clipInfo[c];
                        float weight = info.weight * layerWeight;
                        if (weight == 0)
                        {
                            continue;
                        }

                        float time = stateInfo.normalizedTime * info.clip.length;
                        animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, events, weight);
                                                #if USE_SPINE_EVENTS
                        FireEvents(events, weight, this.AnimationEvent);
                                                #endif
                    }
                                        #if UNITY_5
                    if (nextStateInfo.fullPathHash != 0)
                    {
                                        #else
                    if (nextStateInfo.nameHash != 0)
                    {
                                        #endif
                        for (int c = 0; c < nextClipInfo.Length; c++)
                        {
                            var   info   = nextClipInfo[c];
                            float weight = info.weight * layerWeight;
                            if (weight == 0)
                            {
                                continue;
                            }

                            float time = nextStateInfo.normalizedTime * info.clip.length;
                            animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, events, weight);
                                                        #if USE_SPINE_EVENTS
                            FireEvents(events, weight, this.AnimationEvent);
                                                        #endif
                        }
                    }
                }
                else if (mode >= MixMode.MixNext)
                {
                    //apply first non-zero weighted clip
                    int c = 0;

                    for (; c < clipInfo.Length; c++)
                    {
                        var   info   = clipInfo[c];
                        float weight = info.weight * layerWeight;
                        if (weight == 0)
                        {
                            continue;
                        }

                        float time = stateInfo.normalizedTime * info.clip.length;
                        animationTable[GetAnimationClipNameHashCode(info.clip)].Apply(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, events);
                                                #if USE_SPINE_EVENTS
                        FireEvents(events, weight, this.AnimationEvent);
                                                #endif
                        break;
                    }

                    //mix the rest
                    for (; c < clipInfo.Length; c++)
                    {
                        var   info   = clipInfo[c];
                        float weight = info.weight * layerWeight;
                        if (weight == 0)
                        {
                            continue;
                        }

                        float time = stateInfo.normalizedTime * info.clip.length;
                        animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, stateInfo.loop, events, weight);
                                                #if USE_SPINE_EVENTS
                        FireEvents(events, weight, this.AnimationEvent);
                                                #endif
                    }

                    c = 0;
                                        #if UNITY_5
                    if (nextStateInfo.fullPathHash != 0)
                    {
                                        #else
                    if (nextStateInfo.nameHash != 0)
                    {
                                        #endif
                        //apply next clip directly instead of mixing (ie:  no crossfade, ignores mecanim transition weights)
                        if (mode == MixMode.SpineStyle)
                        {
                            for (; c < nextClipInfo.Length; c++)
                            {
                                var   info   = nextClipInfo[c];
                                float weight = info.weight * layerWeight;
                                if (weight == 0)
                                {
                                    continue;
                                }

                                float time = nextStateInfo.normalizedTime * info.clip.length;
                                animationTable[GetAnimationClipNameHashCode(info.clip)].Apply(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, events);
                                                                #if USE_SPINE_EVENTS
                                FireEvents(events, weight, this.AnimationEvent);
                                                                #endif
                                break;
                            }
                        }

                        //mix the rest
                        for (; c < nextClipInfo.Length; c++)
                        {
                            var   info   = nextClipInfo[c];
                            float weight = info.weight * layerWeight;
                            if (weight == 0)
                            {
                                continue;
                            }

                            float time = nextStateInfo.normalizedTime * info.clip.length;
                            animationTable[GetAnimationClipNameHashCode(info.clip)].Mix(skeleton, Mathf.Max(0, time - deltaTime), time, nextStateInfo.loop, events, weight);
                                                        #if USE_SPINE_EVENTS
                            FireEvents(events, weight, this.AnimationEvent);
                                                        #endif
                        }
                    }
                }
            }

            if (_UpdateLocal != null)
            {
                _UpdateLocal(this);
            }

            skeleton.UpdateWorldTransform();

            if (_UpdateWorld != null)
            {
                _UpdateWorld(this);
                skeleton.UpdateWorldTransform();
            }

            if (_UpdateComplete != null)
            {
                _UpdateComplete(this);
            }

            lastTime = Time.time;
        }
            public void Apply(Skeleton skeleton)
            {
                if (this.layerMixModes.Length < this.animator.layerCount)
                {
                    Array.Resize <MixMode>(ref this.layerMixModes, this.animator.layerCount);
                }
                if (this.autoReset)
                {
                    List <Spine.Animation> previousAnimations = this.previousAnimations;
                    int num   = 0;
                    int count = previousAnimations.Count;
                    while (num < count)
                    {
                        previousAnimations[num].SetKeyedItemsToSetupPose(skeleton);
                        num++;
                    }
                    previousAnimations.Clear();
                    int num3 = 0;
                    int num4 = this.animator.layerCount;
                    while (num3 < num4)
                    {
                        float num5 = (num3 != 0) ? this.animator.GetLayerWeight(num3) : 1f;
                        if (num5 > 0f)
                        {
                            bool flag = this.animator.GetNextAnimatorStateInfo(num3).fullPathHash != 0;
                            this.GetAnimatorClipInfos(num3, out int num6, out int num7, out IList <AnimatorClipInfo> list2, out IList <AnimatorClipInfo> list3);
                            for (int i = 0; i < num6; i++)
                            {
                                AnimatorClipInfo info2 = list2[i];
                                float            num9  = info2.weight * num5;
                                if (num9 != 0f)
                                {
                                    previousAnimations.Add(this.GetAnimation(info2.clip));
                                }
                            }
                            if (flag)
                            {
                                for (int j = 0; j < num7; j++)
                                {
                                    AnimatorClipInfo info3 = list3[j];
                                    float            num11 = info3.weight * num5;
                                    if (num11 != 0f)
                                    {
                                        previousAnimations.Add(this.GetAnimation(info3.clip));
                                    }
                                }
                            }
                        }
                        num3++;
                    }
                }
                int layerIndex = 0;
                int layerCount = this.animator.layerCount;

                while (layerIndex < layerCount)
                {
                    float             num14 = (layerIndex != 0) ? this.animator.GetLayerWeight(layerIndex) : 1f;
                    AnimatorStateInfo currentAnimatorStateInfo = this.animator.GetCurrentAnimatorStateInfo(layerIndex);
                    AnimatorStateInfo nextAnimatorStateInfo    = this.animator.GetNextAnimatorStateInfo(layerIndex);
                    bool flag2 = nextAnimatorStateInfo.fullPathHash != 0;
                    this.GetAnimatorClipInfos(layerIndex, out int num15, out int num16, out IList <AnimatorClipInfo> list4, out IList <AnimatorClipInfo> list5);
                    MixMode mode = this.layerMixModes[layerIndex];
                    if (mode == MixMode.AlwaysMix)
                    {
                        for (int i = 0; i < num15; i++)
                        {
                            AnimatorClipInfo info6 = list4[i];
                            float            alpha = info6.weight * num14;
                            if (alpha != 0f)
                            {
                                float time = AnimationTime(currentAnimatorStateInfo.normalizedTime, info6.clip.length, currentAnimatorStateInfo.loop, currentAnimatorStateInfo.speed < 0f);
                                this.GetAnimation(info6.clip).Apply(skeleton, 0f, time, currentAnimatorStateInfo.loop, null, alpha, MixPose.Current, MixDirection.In);
                            }
                        }
                        if (flag2)
                        {
                            for (int j = 0; j < num16; j++)
                            {
                                AnimatorClipInfo info7 = list5[j];
                                float            alpha = info7.weight * num14;
                                if (alpha != 0f)
                                {
                                    float time = AnimationTime(nextAnimatorStateInfo.normalizedTime, info7.clip.length, nextAnimatorStateInfo.speed < 0f);
                                    this.GetAnimation(info7.clip).Apply(skeleton, 0f, time, nextAnimatorStateInfo.loop, null, alpha, MixPose.Current, MixDirection.In);
                                }
                            }
                        }
                    }
                    else
                    {
                        int num21 = 0;
                        while (num21 < num15)
                        {
                            AnimatorClipInfo info8 = list4[num21];
                            float            num22 = info8.weight * num14;
                            if (num22 != 0f)
                            {
                                float time = AnimationTime(currentAnimatorStateInfo.normalizedTime, info8.clip.length, currentAnimatorStateInfo.loop, currentAnimatorStateInfo.speed < 0f);
                                this.GetAnimation(info8.clip).Apply(skeleton, 0f, time, currentAnimatorStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
                                break;
                            }
                            num21++;
                        }
                        while (num21 < num15)
                        {
                            AnimatorClipInfo info9 = list4[num21];
                            float            alpha = info9.weight * num14;
                            if (alpha != 0f)
                            {
                                float time = AnimationTime(currentAnimatorStateInfo.normalizedTime, info9.clip.length, currentAnimatorStateInfo.loop, currentAnimatorStateInfo.speed < 0f);
                                this.GetAnimation(info9.clip).Apply(skeleton, 0f, time, currentAnimatorStateInfo.loop, null, alpha, MixPose.Current, MixDirection.In);
                            }
                            num21++;
                        }
                        num21 = 0;
                        if (flag2)
                        {
                            if (mode == MixMode.SpineStyle)
                            {
                                while (num21 < num16)
                                {
                                    AnimatorClipInfo info10 = list5[num21];
                                    float            num24  = info10.weight * num14;
                                    if (num24 != 0f)
                                    {
                                        float time = AnimationTime(nextAnimatorStateInfo.normalizedTime, info10.clip.length, nextAnimatorStateInfo.speed < 0f);
                                        this.GetAnimation(info10.clip).Apply(skeleton, 0f, time, nextAnimatorStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
                                        break;
                                    }
                                    num21++;
                                }
                            }
                            while (num21 < num16)
                            {
                                AnimatorClipInfo info11 = list5[num21];
                                float            alpha  = info11.weight * num14;
                                if (alpha != 0f)
                                {
                                    float time = AnimationTime(nextAnimatorStateInfo.normalizedTime, info11.clip.length, nextAnimatorStateInfo.speed < 0f);
                                    this.GetAnimation(info11.clip).Apply(skeleton, 0f, time, nextAnimatorStateInfo.loop, null, alpha, MixPose.Current, MixDirection.In);
                                }
                                num21++;
                            }
                        }
                    }
                    layerIndex++;
                }
            }
Beispiel #20
0
            public void Apply(Skeleton skeleton)
            {
                if (layerMixModes.Length < animator.layerCount)
                {
                    Array.Resize(ref layerMixModes, animator.layerCount);
                }
                if (autoReset)
                {
                    List <Animation> list = previousAnimations;
                    int i = 0;
                    for (int count = list.Count; i < count; i++)
                    {
                        list[i].SetKeyedItemsToSetupPose(skeleton);
                    }
                    list.Clear();
                    int j = 0;
                    for (int layerCount = animator.layerCount; j < layerCount; j++)
                    {
                        float num = (j != 0) ? animator.GetLayerWeight(j) : 1f;
                        if (num <= 0f)
                        {
                            continue;
                        }
                        bool flag = animator.GetNextAnimatorStateInfo(j).fullPathHash != 0;
                        GetAnimatorClipInfos(j, out int clipInfoCount, out int nextClipInfoCount, out IList <AnimatorClipInfo> clipInfo, out IList <AnimatorClipInfo> nextClipInfo);
                        for (int k = 0; k < clipInfoCount; k++)
                        {
                            AnimatorClipInfo animatorClipInfo = clipInfo[k];
                            float            num2             = animatorClipInfo.weight * num;
                            if (num2 != 0f)
                            {
                                list.Add(animationTable[NameHashCode(animatorClipInfo.clip)]);
                            }
                        }
                        if (!flag)
                        {
                            continue;
                        }
                        for (int l = 0; l < nextClipInfoCount; l++)
                        {
                            AnimatorClipInfo animatorClipInfo2 = nextClipInfo[l];
                            float            num3 = animatorClipInfo2.weight * num;
                            if (num3 != 0f)
                            {
                                list.Add(animationTable[NameHashCode(animatorClipInfo2.clip)]);
                            }
                        }
                    }
                }
                int m = 0;

                for (int layerCount2 = animator.layerCount; m < layerCount2; m++)
                {
                    float             num4 = (m != 0) ? animator.GetLayerWeight(m) : 1f;
                    AnimatorStateInfo currentAnimatorStateInfo = animator.GetCurrentAnimatorStateInfo(m);
                    AnimatorStateInfo nextAnimatorStateInfo    = animator.GetNextAnimatorStateInfo(m);
                    bool flag2 = nextAnimatorStateInfo.fullPathHash != 0;
                    GetAnimatorClipInfos(m, out int clipInfoCount2, out int nextClipInfoCount2, out IList <AnimatorClipInfo> clipInfo2, out IList <AnimatorClipInfo> nextClipInfo2);
                    MixMode mixMode = layerMixModes[m];
                    if (mixMode == MixMode.AlwaysMix)
                    {
                        for (int n = 0; n < clipInfoCount2; n++)
                        {
                            AnimatorClipInfo animatorClipInfo3 = clipInfo2[n];
                            float            num5 = animatorClipInfo3.weight * num4;
                            if (num5 != 0f)
                            {
                                animationTable[NameHashCode(animatorClipInfo3.clip)].Apply(skeleton, 0f, AnimationTime(currentAnimatorStateInfo.normalizedTime, animatorClipInfo3.clip.length, currentAnimatorStateInfo.loop, currentAnimatorStateInfo.speed < 0f), currentAnimatorStateInfo.loop, null, num5, MixPose.Current, MixDirection.In);
                            }
                        }
                        if (!flag2)
                        {
                            continue;
                        }
                        for (int num6 = 0; num6 < nextClipInfoCount2; num6++)
                        {
                            AnimatorClipInfo animatorClipInfo4 = nextClipInfo2[num6];
                            float            num7 = animatorClipInfo4.weight * num4;
                            if (num7 != 0f)
                            {
                                animationTable[NameHashCode(animatorClipInfo4.clip)].Apply(skeleton, 0f, AnimationTime(nextAnimatorStateInfo.normalizedTime, animatorClipInfo4.clip.length, nextAnimatorStateInfo.speed < 0f), nextAnimatorStateInfo.loop, null, num7, MixPose.Current, MixDirection.In);
                            }
                        }
                        continue;
                    }
                    int num8;
                    for (num8 = 0; num8 < clipInfoCount2; num8++)
                    {
                        AnimatorClipInfo animatorClipInfo5 = clipInfo2[num8];
                        float            num9 = animatorClipInfo5.weight * num4;
                        if (num9 != 0f)
                        {
                            animationTable[NameHashCode(animatorClipInfo5.clip)].Apply(skeleton, 0f, AnimationTime(currentAnimatorStateInfo.normalizedTime, animatorClipInfo5.clip.length, currentAnimatorStateInfo.loop, currentAnimatorStateInfo.speed < 0f), currentAnimatorStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
                            break;
                        }
                    }
                    for (; num8 < clipInfoCount2; num8++)
                    {
                        AnimatorClipInfo animatorClipInfo6 = clipInfo2[num8];
                        float            num10             = animatorClipInfo6.weight * num4;
                        if (num10 != 0f)
                        {
                            animationTable[NameHashCode(animatorClipInfo6.clip)].Apply(skeleton, 0f, AnimationTime(currentAnimatorStateInfo.normalizedTime, animatorClipInfo6.clip.length, currentAnimatorStateInfo.loop, currentAnimatorStateInfo.speed < 0f), currentAnimatorStateInfo.loop, null, num10, MixPose.Current, MixDirection.In);
                        }
                    }
                    num8 = 0;
                    if (!flag2)
                    {
                        continue;
                    }
                    if (mixMode == MixMode.SpineStyle)
                    {
                        for (; num8 < nextClipInfoCount2; num8++)
                        {
                            AnimatorClipInfo animatorClipInfo7 = nextClipInfo2[num8];
                            float            num11             = animatorClipInfo7.weight * num4;
                            if (num11 != 0f)
                            {
                                animationTable[NameHashCode(animatorClipInfo7.clip)].Apply(skeleton, 0f, AnimationTime(nextAnimatorStateInfo.normalizedTime, animatorClipInfo7.clip.length, nextAnimatorStateInfo.speed < 0f), nextAnimatorStateInfo.loop, null, 1f, MixPose.Current, MixDirection.In);
                                break;
                            }
                        }
                    }
                    for (; num8 < nextClipInfoCount2; num8++)
                    {
                        AnimatorClipInfo animatorClipInfo8 = nextClipInfo2[num8];
                        float            num12             = animatorClipInfo8.weight * num4;
                        if (num12 != 0f)
                        {
                            animationTable[NameHashCode(animatorClipInfo8.clip)].Apply(skeleton, 0f, AnimationTime(nextAnimatorStateInfo.normalizedTime, animatorClipInfo8.clip.length, nextAnimatorStateInfo.speed < 0f), nextAnimatorStateInfo.loop, null, num12, MixPose.Current, MixDirection.In);
                        }
                    }
                }
            }