示例#1
0
        private void LateUpdate()
        {
            if (_audio.isPlaying)
            {
                _audio.GetOutputData(array, 0);
                float num3 = 0f;
                for (int i = 0; i < width; i++)
                {
                    float num4 = Mathf.Abs(array[i]);
                    num3 += num4;
                }
                num3 /= (float)width;
                if (Options.GetSpeechVolume() > 0f)
                {
                    num3 /= Options.GetSpeechVolume();
                }

                // Only record changes big enough
                if (Mathf.Abs(num3 - volume) > bin)
                {
                    volume = num3;
                }

                volume  = Mathf.Clamp01(volume * 2);
                volume *= 0.3f;

                output = Mathf.Lerp(output, volume, Time.deltaTime * Mathf.Abs(rotationFactor));
            }
            else
            {
                output = 0f;
            }

            if (_character != null && !_character.isTalking && Mathf.Approximately(output, 0f))
            {
                return;
            }

            jawRotation = (isAdditive) ? jawBone.localRotation : originalRotation;

            if (coordinateToAffect == Coord.W)
            {
                if (rotationFactor < 0)
                {
                    jawRotation.w += output;
                }
                else
                {
                    jawRotation.w -= output;
                }
            }
            else if (coordinateToAffect == Coord.X)
            {
                if (rotationFactor < 0)
                {
                    jawRotation.x += output;
                }
                else
                {
                    jawRotation.x -= output;
                }
            }
            else if (coordinateToAffect == Coord.Y)
            {
                if (rotationFactor < 0)
                {
                    jawRotation.y += output;
                }
                else
                {
                    jawRotation.y -= output;
                }
            }
            else if (coordinateToAffect == Coord.Z)
            {
                if (rotationFactor < 0)
                {
                    jawRotation.z += output;
                }
                else
                {
                    jawRotation.z -= output;
                }
            }

            jawBone.localRotation = jawRotation;
        }