Ejemplo n.º 1
0
    // Update is called once per frame
    void Update()
    {
        // Reset spellbook content
        if (Input.GetKeyDown("b"))
        {
            spellPageTextures.Clear();
            spellPageTextures.AddRange(spellbookStartPages);
            targetPage = 0;
            TriggerEffect(Color.red);
        }
        int   nLookups    = Mathf.CeilToInt(spellPageTextures.Count / 2f);
        float inputDelta  = 0;
        bool  inputActive = IsInputActive();
        bool  inputDown   = inputActive && !wasInputActive;
        bool  inputUp     = wasInputActive && !inputActive;

        wasInputActive = inputActive;
        // Press
        if (inputDown)
        {
            inputStartPosition = GetInputValue();
        }
        // Holding
        if (inputActive)
        {
            inputDelta = Mathf.Clamp(-(GetInputValue() - inputStartPosition), -1f, 1f);
            // inputDelta = -(GetInputValue() - inputStartPosition);
            contLookupWithInput = Mathf.Clamp(contLookup + inputDelta, 0, nLookups - 1);
            visibleLookup       = Mathf.FloorToInt(contLookupWithInput);
            flipPageProgress    = contLookupWithInput % 1;
        }
        // Release
        if (inputUp)
        {
            contLookup = contLookupWithInput;
            targetPage = Mathf.Round(contLookup);
        }
        // Not holding
        if (!inputActive)
        {
            contLookup = Mathf.Lerp(contLookup, targetPage, Time.deltaTime * 10);
            if (contLookup < 0.01f)
            {
                contLookup = 0;
            }
            visibleLookup    = Mathf.FloorToInt(contLookup);
            flipPageProgress = contLookup % 1;
        }
        var sinFlip    = Mathf.Sin((1 - flipPageProgress) * Mathf.PI / 2);
        var blendValue = sinFlip * sinFlip;

        // var blendValue = 1-flipPageProgress;
        if (page2 && page4)
        {
            page2.SetBlendShapeWeight(0, blendValue * 100);
            page2.SetBlendShapeWeight(1, Mathf.Sin(blendValue * Mathf.PI) * 100);
            page3.SetBlendShapeWeight(0, blendValue * 100);
            page3.SetBlendShapeWeight(1, Mathf.Sin(blendValue * Mathf.PI) * 100);
        }
        UpdatePageTextures();
        UpdateEmission();
    }
Ejemplo n.º 2
0
    //public void Smile() {

    //    int value = Random.Range(0,2);

    //    if (blendShapes != null) {
    //        blendShapes.SetBlendShapeWeight(0, value * 100);
    //    }
    //}


    #region FemaleCoffe

    IEnumerator FemaleCoffe_EyesAnimation()
    {
        if (blendShapes != null)
        {
            blendShapes.SetBlendShapeWeight(1, 0);

            yield return(new WaitForSeconds(0.2f));

            blendShapes.SetBlendShapeWeight(1, 100);

            yield return(new WaitForSeconds(0.2f));

            blendShapes.SetBlendShapeWeight(1, 0);
        }
    }
Ejemplo n.º 3
0
    // Update is called once per frame
    void Update()
    {
        if (EnableReading.isLookingAtTablet)
        {
            // If Anna is looking at the tablet, she will not blink but her eyebrows will be slightly down.
            eyelidFraction = 75.0f;
            //skinnedMeshRenderer.SetBlendShapeWeight(5, 30);
        }
        else
        {
            eyelidFraction = 30.0f;
        }

        // Anna will blink at random intervals. The animation consists of 3 parts:
        // Eyelids moving downward, eyelids pausing, eyelids moving upward.
        // After the animation a new interval is selected.
        if (blinking)
        {
            if (!hasStarted)
            {
                if (Time.time < lerpEnd)
                {
                    skinnedMeshRenderer.SetBlendShapeWeight(5, eyelidFraction + ((100.0f - eyelidFraction) * (1 -
                                                                                                              ((lerpEnd - Time.time) / startDuration))));
                }
                else
                {
                    hasStarted = true;
                    skinnedMeshRenderer.SetBlendShapeWeight(5, 100);
                    lerpEnd = Time.time + pauseDuration;
                }
            }
            else if (!hasPaused)
            {
                if (Time.time > lerpEnd)
                {
                    hasPaused = true;
                    lerpEnd   = Time.time + endDuration;
                }
            }
            else
            {
                if (Time.time < lerpEnd)
                {
                    skinnedMeshRenderer.SetBlendShapeWeight(5, eyelidFraction + ((100.0f - eyelidFraction) * (lerpEnd - Time.time) / endDuration));
                }
                else
                {
                    blinking     = false;
                    lastBlinkEnd = Time.time;
                    currentWait  = wait
                                   + Random.Range(waitRandomMin, waitRanomMax);
                    if (currentWait <= 0.0f)
                    {
                        currentWait = 6.0f;
                    }
                    if (currentWait >= 10.0f)
                    {
                        currentWait = 6.0f;
                    }

                    hasStarted = false;
                    hasPaused  = false;
                }
            }
        }
        else
        {
            skinnedMeshRenderer.SetBlendShapeWeight(5, eyelidFraction);
            if (Time.time >= lastBlinkEnd + currentWait)
            {
                blinking = true;
                lerpEnd  = Time.time + startDuration;
            }
        }
    }
Ejemplo n.º 4
0
    // Update is called once per frame
    void Update()
    {
        switch ((int)TextureSlider.value)
        {
        case 0:
            blendShape.material = material01;
            break;

        case 1:
            blendShape.material = material02;
            break;

        case 2:
            blendShape.material = material03;
            break;

        case 3:
            blendShape.material = material04;
            break;

        default:
            blendShape.material = material01;
            break;
        }

        if (FLengthSlider.value > 0)
        {
            blendShape.SetBlendShapeWeight(0, FLengthSlider.value);
            finBlendShape.SetBlendShapeWeight(0, FLengthSlider.value);
            spikyBlendShape.SetBlendShapeWeight(0, FLengthSlider.value);
            roundBlendShape.SetBlendShapeWeight(0, FLengthSlider.value);
            flatBlendShape.SetBlendShapeWeight(0, FLengthSlider.value);
        }
        else
        {
            blendShape.SetBlendShapeWeight(1, FLengthSlider.value * -1);
            finBlendShape.SetBlendShapeWeight(1, FLengthSlider.value * -1);
            spikyBlendShape.SetBlendShapeWeight(1, FLengthSlider.value * -1);
            roundBlendShape.SetBlendShapeWeight(1, FLengthSlider.value * -1);
            flatBlendShape.SetBlendShapeWeight(1, FLengthSlider.value * -1);
        }
        if (FWidthSlider.value < 0)
        {
            blendShape.SetBlendShapeWeight(2, FWidthSlider.value * -1);
            finBlendShape.SetBlendShapeWeight(2, FWidthSlider.value * -1);
            spikyBlendShape.SetBlendShapeWeight(2, FWidthSlider.value * -1);
            roundBlendShape.SetBlendShapeWeight(2, FWidthSlider.value * -1);
            flatBlendShape.SetBlendShapeWeight(2, FWidthSlider.value * -1);
        }
        else
        {
            blendShape.SetBlendShapeWeight(3, FWidthSlider.value);
            finBlendShape.SetBlendShapeWeight(3, FWidthSlider.value);
            spikyBlendShape.SetBlendShapeWeight(3, FWidthSlider.value);
            roundBlendShape.SetBlendShapeWeight(3, FWidthSlider.value);
            flatBlendShape.SetBlendShapeWeight(3, FWidthSlider.value);
        }
        if (BLengthSlider.value > 0)
        {
            blendShape.SetBlendShapeWeight(4, BLengthSlider.value);
        }
        else
        {
            blendShape.SetBlendShapeWeight(5, BLengthSlider.value * -1);
        }
        if (BWidthSlider.value > 0)
        {
            blendShape.SetBlendShapeWeight(6, BWidthSlider.value);
        }
        else
        {
            blendShape.SetBlendShapeWeight(7, BWidthSlider.value * -1);
        }
    }
Ejemplo n.º 5
0
    void Update()
    {
        float distance = Vector3.Distance(transform.position, attachedArrow.position);

        BowSkinnedMesh.SetBlendShapeWeight(0, Mathf.Max(0, distance * blendMultiplier));
    }
Ejemplo n.º 6
0
    void Update()
    {
        // Blinking function
        switch (blinkFunctionSelect)
        {
        case 1:
        {
            // Blinking Function version 1 -- Piecewise Function
            // Set weight for left eye
            if (leftEyeShape[1] < 0.05f) //闭眼 //参数匹配:ParameterServer -> 参数控制!闭眼
            {
                leftEyeWeight = 100;
            }
            else if (leftEyeShape[1] < 0.1f)
            {
                leftEyeWeight = 5 / leftEyeShape[1];
            }
            else if (leftEyeShape[1] < 0.2f)
            {
                leftEyeWeight = -500 * leftEyeShape[1] + 100;
            }
            else
            {
                leftEyeWeight = 0;
            }
            // Set weight for right eye
            if (rightEyeShape[1] < 0.05f)
            {
                rightEyeWeight = 100;
            }
            else if (rightEyeShape[1] < 0.1f)
            {
                rightEyeWeight = 5 / rightEyeShape[1];
            }
            else if (rightEyeShape[1] < 0.2f)
            {
                rightEyeWeight = -500 * rightEyeShape[1] + 100;
            }
            else
            {
                rightEyeWeight = 0;
            }

            break;
        }

        case 2:
        {
            // Blinking Function version 2 -- Sigmoid Function
            leftEyeWeight  = 100 - 100 / (1 + Mathf.Exp(-500 * (leftEyeShape[1] - 0.12f)));
            rightEyeWeight = 100 - 100 / (1 + Mathf.Exp(-500 * (rightEyeShape[1] - 0.12f)));
            break;
        }

        default: { Debug.Log("Please Select a Blinking Function."); break; }
        }

        // Shocked function
        if (rightEyeShape[1] > 0.25f)//惊愕 0.25-0.35线性
        {
            shockEyeWeight = 500 * rightEyeShape[1] - 125;
        }
        else
        {
            shockEyeWeight = 0;
        }

        // Mouth deformation function
        if (500 * mouthShape[1] < 100f)
        {
            mouthWidWeight = 500 * mouthShape[1];
        }
        else
        {
            mouthWidWeight = 100f;
        }

        if (mouthShape[0] < 0.1f)
        {
            mouthLenWeight = 50;
        }
        else if (mouthShape[0] < 0.4f)
        {
            mouthLenWeight = 120f - 400 * mouthShape[0];
        }
        else
        {
            // mouthLenWeight = 0;
        }

        // Apply deformation weights
        skinnedMeshRenderer.SetBlendShapeWeight(leftEyeNum, leftEyeWeight);
        skinnedMeshRenderer.SetBlendShapeWeight(rightEyeNum, rightEyeWeight);
        skinnedMeshRenderer.SetBlendShapeWeight(mouthWidNum, mouthWidWeight);
        skinnedMeshRenderer.SetBlendShapeWeight(mouthLenNum, mouthLenWeight);
        skinnedMeshRenderer.SetBlendShapeWeight(shockEyeNum, shockEyeWeight);
    }
Ejemplo n.º 7
0
    /*	Set the corrective pose blendshape values from current pose-parameters (joint angles)
     */
    void setPoseBlendValues()
    {
        Transform[] _bones = _modifyBones.getBones();
        Dictionary <string, int> _boneNameToJointIndex = _modifyBones.getB2J_indices();
        string _boneNamePrefix   = _modifyBones.getBoneNamePrefix();
        int    doubledShapeParms = _numShapeParms * 2;

        for (int i = 0; i < _bones.Length; i++)
        {
            int    index;
            string boneName = _bones[i].name;

            // Remove f_avg/m_avg prefix
            boneName = boneName.Replace(_boneNamePrefix, "");

            if (boneName == "root" || boneName == "Pelvis")
            {
                continue;
            }

            if (_boneNameToJointIndex.TryGetValue(boneName, out index))
            {
                float[] rot3x3 = Quat_to_3x3Mat(_bones[i].localRotation);

                // Can't use the 'index' value as-is from the _boneNameToJointIndex dict;
                // The pose blendshapes have no values corresponding to Pelvis joint.
                // Poseblendshapes start from hip-joint instead of Pelvis.
                // So we have to begin pose_blend indices from 'index-1'
                int idx = (index - 1) * 9 * 2;

                for (int mat_elem = 0; mat_elem < 9; mat_elem++)
                {
                    float pos, neg;
                    float theta = rot3x3 [mat_elem];

                    if (theta >= 0)
                    {
                        pos = theta;
                        neg = 0.0f;
                    }
                    else
                    {
                        pos = 0.0f;
                        neg = -theta;
                    }

                    int non_doubled_idx = ((index - 1) * 9) + mat_elem;

                    if (optimizePoseBlends)
                    {
                        if (!_poseBlendsToSet.Contains(non_doubled_idx))
                        {
                            continue;
                        }
                    }
                    int bl_idx_0 = doubledShapeParms + idx + (mat_elem * 2) + 0;
                    int bl_idx_1 = doubledShapeParms + idx + (mat_elem * 2) + 1;
                    targetMeshRenderer.SetBlendShapeWeight(bl_idx_0, pos * 100.0f);
                    targetMeshRenderer.SetBlendShapeWeight(bl_idx_1, neg * 100.0f);
                }
            }
        }
    }
Ejemplo n.º 8
0
        void LateUpdate()
        {
            //Look at
            ComputeKinematic(m_headLook);

            //tail
            ComputeKinematic(m_tailLook);


            //jaw
            m_openJaw       = Mathf.Clamp01(m_openJaw);
            m_fireIntensity = Mathf.Clamp01(m_fireIntensity);
            float openJaw = Mathf.Max(m_openJaw, m_fireIntensity);

            if (m_jaw != null)
            {
                if (openJaw > 0)
                {
                    m_jaw.localRotation = Quaternion.Euler(-180f, Mathf.Lerp(m_jawLimits.x, m_jawLimits.y, openJaw), 0f);
                }

                //tong
                float fullAngle = Quaternion.Angle(Quaternion.Euler(-180f, m_jawLimits.x, 0f), Quaternion.Euler(-180f, m_jawLimits.y, 0f));
                float openAngle = Quaternion.Angle(m_jaw.localRotation, Quaternion.Euler(-180f, m_jawLimits.x, 0f));
                m_tongMesh.SetBlendShapeWeight(0, (openAngle / fullAngle) * 100f * (1f - m_fireIntensity));
            }



            //eyes
            m_closeEyes = Mathf.Clamp01(m_closeEyes);
            if (m_closeEyes == 0f)
            {
                if (Time.time - m_lastBlinkTime > m_blinkRate * .8f + m_blinkRate * .2f * Random.value)
                {
                    m_blink = true;
                }

                if (m_blink)
                {
                    m_blinkWeight += Time.deltaTime * 8f;
                    m_blinkWeight  = Mathf.Clamp01(m_blinkWeight);
                    if (m_blinkWeight == 1f)
                    {
                        m_blink         = false;
                        m_lastBlinkTime = Time.time;
                    }
                }
                else
                {
                    m_blinkWeight -= Time.deltaTime * 3f;
                    m_blinkWeight  = Mathf.Clamp01(m_blinkWeight);
                }

                m_dragonMesh.SetBlendShapeWeight(0, m_blinkWeight * 100f);
            }
            else
            {
                m_dragonMesh.SetBlendShapeWeight(0, m_closeEyes * 100f);
            }


            m_fire.transform.position          = m_headLook.bones[0].position;
            m_fire.transform.rotation          = m_headLook.bones[0].rotation * Quaternion.Euler(m_headLook.lookAtFix.x + 90f, m_headLook.lookAtFix.y, 0f);
            m_headLook.bones[0].localRotation *= Quaternion.Lerp(Quaternion.identity, Quaternion.Euler(0f, -30f, 0f), openJaw);


            m_fireEmission = Mathf.Lerp(m_fireEmission, m_fireIntensity, Time.deltaTime * .3f);

            //m_dragonMesh.material.globalIlluminationFlags = MaterialGlobalIlluminationFlags.RealtimeEmissive;
            m_dragonMesh.material.SetColor("_EmissionColor", Color.Lerp(Color.black, Color.white, m_fireEmission));
            m_tongMesh.material = m_dragonMesh.material;
            //DynamicGI.UpdateMaterials(m_dragonMesh);
            //DynamicGI.UpdateMaterials(m_tongMesh);
            //DynamicGI.UpdateEnvironment();

            m_light.intensity = 8f * m_fireIntensity;

            m_fire.m_intensity          = m_fireIntensity;
            m_fire.transform.localScale = transform.localScale;
        }
Ejemplo n.º 9
0
 private void HandleBlendshape()
 {
     m_openAmount = Mathf.Clamp(m_openAmount + Time.deltaTime * (m_isOpen ? 500f : -500f), 0, 100f);
     m_meshRenderer.SetBlendShapeWeight(0, m_openAmount);
 }
Ejemplo n.º 10
0
 void WeightISChanged(int index, float f)
 {
     skinnedMeshRenderer.SetBlendShapeWeight(index, f);
 }
Ejemplo n.º 11
0
 private void Morph()
 {
     MorphProgress += ArrowState ? -morphSpeed : morphSpeed;
     _meshRenderer.SetBlendShapeWeight(0, _morphProgress);
 }
Ejemplo n.º 12
0
 // ランダムまばたき
 private void BlendShapeRandomMabataki()
 {
     if (_mabataki_on)
     {
         _pastsecm += Time.deltaTime;
         if (_pastsecm > _nextsecm)
         {
             _nextsecm = Random.Range(4.0f, 7.5f);                    // 4~7.5秒ごとにまばたきする
             _pastsecm = 0.0f;
         }
         if (_pastsecm < 0.2f)
         {
             if (_pastsecm < 0.1f)
             {
                 _Mabataki_Weight += (Time.deltaTime / 0.1f) * 100f;
                 if (_Mabataki_Weight > 99.9f)
                 {
                     _Mabataki_Weight = 100f;
                 }
                 m_Face.SetBlendShapeWeight(s2i(_mabataki_shapeky), _Mabataki_Weight);
             }
             else if (_pastsecm < 0.2f)
             {
                 _Mabataki_Weight -= (Time.deltaTime / 0.1f) * 100f;
                 if (_Mabataki_Weight < 0.01f)
                 {
                     _Mabataki_Weight = 0.0f;
                 }
                 m_Face.SetBlendShapeWeight(s2i(_mabataki_shapeky), _Mabataki_Weight);
             }
         }
     }
     else
     {
         m_Face.SetBlendShapeWeight(s2i(_mabataki_shapeky), 0f);
     }
 }
Ejemplo n.º 13
0
        public BlendShapeMerger(IEnumerable <BlendShapeClip> clips, Transform root)
        {
            m_materialMap = new Dictionary <string, Material>();
            foreach (var x in root.Traverse())
            {
                var renderer = x.GetComponent <Renderer>();
                if (renderer != null)
                {
                    foreach (var y in renderer.sharedMaterials.Where(y => y != null))
                    {
                        if (!string.IsNullOrEmpty(y.name))
                        {
                            if (!m_materialMap.ContainsKey(y.name))
                            {
                                m_materialMap.Add(y.name, y);
                            }
                        }
                    }
                }
            }

            m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x);

            m_valueMap = new Dictionary <BlendShapeKey, float>();

            foreach (var kv in m_clipMap)
            {
                foreach (var binding in kv.Value.Values)
                {
                    if (!m_blendShapeSetterMap.ContainsKey(binding))
                    {
                        var _target = root.Find(binding.RelativePath);
                        SkinnedMeshRenderer target = null;
                        if (_target != null)
                        {
                            target = _target.GetComponent <SkinnedMeshRenderer>();
                        }
                        if (target != null)
                        {
                            if (binding.Index >= 0 && binding.Index < target.sharedMesh.blendShapeCount)
                            {
                                m_blendShapeSetterMap.Add(binding, x =>
                                {
                                    target.SetBlendShapeWeight(binding.Index, x);
                                });
                            }
                            else
                            {
                                Debug.LogWarningFormat("Invalid blendshape binding: {0}: {1}", target.name, binding);
                            }
                        }
                        else
                        {
                            Debug.LogWarningFormat("SkinnedMeshRenderer: {0} not found", binding.RelativePath);
                        }
                    }
                }

                foreach (var binding in kv.Value.MaterialValues)
                {
                    if (!m_materialSetterMap.ContainsKey(binding))
                    {
                        Material target;
                        if (m_materialMap.TryGetValue(binding.MaterialName, out target))
                        {
                            if (binding.ValueName.EndsWith("_ST_S"))
                            {
                                var            valueName = binding.ValueName.Substring(0, binding.ValueName.Length - 2);
                                Action <float> setter    = value =>
                                {
                                    var propValue = binding.BaseValue + (binding.TargetValue - binding.BaseValue) * value;
                                    var src       = target.GetVector(valueName);
                                    src.x = propValue.x; // horizontal only
                                    src.z = propValue.z; // horizontal only
                                    target.SetVector(valueName, src);
                                };
                                m_materialSetterMap.Add(binding, setter);
                            }
                            else if (binding.ValueName.EndsWith("_ST_T"))
                            {
                                var            valueName = binding.ValueName.Substring(0, binding.ValueName.Length - 2);
                                Action <float> setter    = value =>
                                {
                                    var propValue = binding.BaseValue + (binding.TargetValue - binding.BaseValue) * value;
                                    var src       = target.GetVector(valueName);
                                    src.y = propValue.y; // vertical only
                                    src.w = propValue.w; // vertical only
                                    target.SetVector(valueName, src);
                                };
                                m_materialSetterMap.Add(binding, setter);
                            }
                            else
                            {
                                Action <float> vec4Setter = x =>
                                {
                                    var propValue = binding.BaseValue + (binding.TargetValue - binding.BaseValue) * x;
                                    target.SetColor(binding.ValueName, propValue);
                                };
                                m_materialSetterMap.Add(binding, vec4Setter);
                            }
                        }
                        else
                        {
                            Debug.LogWarningFormat("material: {0} not found", binding.MaterialName);
                        }
                    }
                }
            }
        }
 void SetCloseEyes()
 {
     ref_face.SetBlendShapeWeight(index_EYE_blk, ratio_Close);
 }
Ejemplo n.º 15
0
    /// <summary>
    /// Animate facial expression blend shapes.
    /// </summary>
    /// <param name="newDirectionL">The gaze direction for the left eye.</param>
    /// <param name="newDirectionR">The gaze direction for the right eye.</param>
    /// <param name="eyeDataLeft">Eye data for the left eye.</param>
    /// <param name="eyeDataRight">Eye data for the right eye.</param>
    private void AnimateFacialExpressions(Vector3 newDirectionL, Vector3 newDirectionR, TobiiXR_EyeTrackingData eyeData)
    {
        // Eyebrows.
        var leftEyeBrowBlendShapeWeight  = -newDirectionL.x * EyeBrowBlendShapeHorizontalFactor + newDirectionL.y * EyeBrowBlendShapeVerticalFactor;
        var rightEyeBrowBlendShapeWeight = newDirectionR.x * EyeBrowBlendShapeHorizontalFactor + newDirectionR.y * EyeBrowBlendShapeVerticalFactor;

        _faceBlendShapes.SetBlendShapeWeight(BlendShapeLeftEyeBrowUp, Mathf.Clamp(leftEyeBrowBlendShapeWeight, 0f, 100f));
        _faceBlendShapes.SetBlendShapeWeight(BlendShapeRightEyeBrowUp, Mathf.Clamp(rightEyeBrowBlendShapeWeight, 0f, 100f));

        // If eye openness data is invalid use last value.
        var leftEyeClosed  = eyeData.IsLeftEyeBlinking;
        var rightEyeClosed = eyeData.IsRightEyeBlinking;

        // Use a timer to filter unintentional winks.
        if (leftEyeClosed ^ rightEyeClosed)
        {
            _winkTimer += Time.deltaTime;
        }
        else
        {
            _winkTimer = 0;
        }

        // If eye openness has changed reset animation curve.
        if (leftEyeClosed != _leftEyeClosed || rightEyeClosed != _rightEyeClosed)
        {
            _animationProgress = 0;
        }

        var leftEyeBlendShapeWinkValue  = (leftEyeClosed && _winkTimer > BlinkWinkTime ? BlendShapeFactor : 0);
        var rightEyeBlendShapeWinkValue = (rightEyeClosed && _winkTimer > BlinkWinkTime ? BlendShapeFactor : 0);

        _winkL = Mathf.Lerp(_winkL, leftEyeBlendShapeWinkValue, _blendShapeAnimationCurve.Evaluate(_animationProgress));
        _winkR = Mathf.Lerp(_winkR, rightEyeBlendShapeWinkValue, _blendShapeAnimationCurve.Evaluate(_animationProgress));

        _faceBlendShapes.SetBlendShapeWeight(BlendShapeLeftWink, Mathf.Clamp(_winkL, 0f, 100f));
        _faceBlendShapes.SetBlendShapeWeight(BlendShapeRightWink, Mathf.Clamp(_winkR, 0f, 100f));
        _teethBlendShapes.SetBlendShapeWeight(BlendShapeTeethLeftWink, Mathf.Clamp(_winkL, 0f, 100f));
        _teethBlendShapes.SetBlendShapeWeight(BlendShapeTeethRightWink, Mathf.Clamp(_winkR, 0f, 100f));

        // Cross eyed snarl.
        if (!leftEyeClosed && !rightEyeClosed)
        {
            var crossEyedness      = Mathf.Abs(newDirectionL.x - newDirectionR.x);
            var crossEyedThisFrame = crossEyedness > CrossEyednessSnarlTriggerValue;
            if (crossEyedThisFrame != _crossEyed)
            {
                _animationProgress = 0;
            }

            _currentSnarlExtent = Mathf.Lerp(_currentSnarlExtent, crossEyedThisFrame ? crossEyedness * BlendShapeFactor : 0, _blendShapeAnimationCurve.Evaluate(_animationProgress));
            _crossEyed          = crossEyedThisFrame;

            _faceBlendShapes.SetBlendShapeWeight(BlendShapeCrossEyedSnarl, Mathf.Clamp(_currentSnarlExtent, 0f, 100f));
        }

        _leftEyeClosed  = leftEyeClosed;
        _rightEyeClosed = rightEyeClosed;

        _animationProgress += Time.deltaTime / _blendShapeAnimationTimeSeconds;
    }
Ejemplo n.º 16
0
 public void GoodHit(float blendAmount)
 {
     blendOne += blendAmount;
     skinnedMeshRenderer.SetBlendShapeWeight(0, blendOne);
 }
Ejemplo n.º 17
0
 //Mathf.Lerp(skinnedMeshRenderer.GetBlendShapeWeight(0),blendGoal,blendSpeed)
 void Update()
 {
     skinnedMeshRenderer.SetBlendShapeWeight(0, Mathf.Lerp(skinnedMeshRenderer.GetBlendShapeWeight(0), blendGoal, blendSpeed * Time.deltaTime));
 }
Ejemplo n.º 18
0
    //Check to see if the player wants to shoot an arrow
    private void ShootArrow()
    {
        if (arrowsRemaining > 0)
        {
            SkinnedMeshRenderer bowSkin   = bow.transform.GetComponent <SkinnedMeshRenderer>();
            SkinnedMeshRenderer arrowSkin = arrow.transform.GetComponent <SkinnedMeshRenderer>();
            Rigidbody           arrowRB   = arrow.transform.GetComponent <Rigidbody>();
            ArrowForce          af        = arrow.transform.GetComponent <ArrowForce>();
            if (Input.GetMouseButtonDown(0))
            {
                Audio_Manager.Play("BowString");
            }

            if (Input.GetMouseButton(0) && !stopDraw)
            {
                if (Input.GetKeyDown(KeyCode.R))
                {
                    stopDraw     = true;
                    drawDistance = 0;
                    ResetBow();
                }

                if (!stopDraw)
                {
                    drawDistance += Time.deltaTime * pullSpeed; //set the draw distance


                    if (drawDistance < 100)
                    {
                        //Move the bow and arrow to be closer as the player draws the string back
                        bow.transform.localPosition += changeBowPos; transform.localPosition += changeArrowPos;
                        bow.transform.localRotation  = Quaternion.Euler(totalHipRotChange += changeRot, -90, 0);

                        totalBowPosChanges   += changeBowPos;
                        totalArrowPosChanges += changeArrowPos;
                    }
                    else
                    {
                        drawDistance = 100;
                        Audio_Manager.Stop("BowString");
                    }
                }
            }

            if (Input.GetMouseButtonUp(0))
            {
                if (stopDraw)
                {
                    stopDraw = false;
                }
                else if (drawDistance >= 10)     //if the draw distance is enough to actually launch the arrow
                {
                    knockedArrow        = false; //set it so the player no longer has an arrow drawn
                    arrowRB.isKinematic = false;

                    Audio_Manager.Play("ArrowShoot");
                    Handheld.Vibrate();
                    arrow.transform.SetParent(null);
                    arrow.transform.position = transform.position;

                    arrowsRemaining -= 1;

                    af.shootForce = af.shootForce * ((drawDistance / 100) + 0.05f); //calculate the force of the arrow based on the draw distance

                    drawDistance  = 0;
                    af.enabled    = true;
                    trail.enabled = true; //enable the trail effect

                    ResetBow();           //reset the bow's rotation and position
                }
                else
                {
                    drawDistance = 0;
                    ResetBow();
                }
            }

            bowSkin.SetBlendShapeWeight(0, drawDistance);
            arrowSkin.SetBlendShapeWeight(0, drawDistance);
        }

        //If the player hit the left mouse and doesn't have an arrow knocked, spawn another arrow
        if (Input.GetMouseButtonDown(0) && !knockedArrow)
        {
            SpawnArrow();
        }
    }
 public void CloseMouthBaebe(float value)
 {
     playaHead.SetBlendShapeWeight(34, 100 - (value * 100)); // MOUTH WITHD
     playaHead.SetBlendShapeWeight(36, 100 - (value * 100)); // MOUTH OPEN
 }
Ejemplo n.º 20
0
    static GameObject CopyMesh(GameObject subject, MegaModifyObject mod)
    {
        GameObject clone = new GameObject();            //(GameObject)GameObject.Instantiate(subject);

        MeshFilter newmf = clone.AddComponent <MeshFilter>();

        SkinnedMeshRenderer oldsmr = subject.GetComponent <SkinnedMeshRenderer>();
        SkinnedMeshRenderer newsmr = null;

        if (oldsmr)
        {
            newsmr = clone.AddComponent <SkinnedMeshRenderer>();

            newsmr.sharedMaterials = oldsmr.sharedMaterials;
        }
        else
        {
            MeshRenderer oldmr = subject.GetComponent <MeshRenderer>();
            MeshRenderer newmr = clone.AddComponent <MeshRenderer>();

            newmr.sharedMaterials = oldmr.sharedMaterials;
        }

        MeshFilter[] mfs = subject.GetComponentsInChildren <MeshFilter>();

        MeshCollider[] mcs      = clone.GetComponentsInChildren <MeshCollider>();
        MeshCollider[] clonemcs = clone.GetComponentsInChildren <MeshCollider>();

        int l = mfs.Length;

        for (int i = 0; i < l; i++)
        {
            MeshFilter mf        = mfs[i];
            Mesh       mesh      = mf.sharedMesh;
            Mesh       clonemesh = new Mesh();

            clonemesh.vertices = mod.verts;             //mesh.vertices;
#if UNITY_5_0 || UNITY_5_1 || UNITY_5 || UNITY_2017
            clonemesh.uv2 = mesh.uv2;
            clonemesh.uv3 = mesh.uv3;
            clonemesh.uv4 = mesh.uv4;
#else
            clonemesh.uv1 = mesh.uv1;
            clonemesh.uv2 = mesh.uv2;
#endif
            clonemesh.uv = mod.uvs;             //mesh.uv;
            if (mod.NormalMethod == MegaNormalMethod.Mega && mod.norms != null && mod.norms.Length > 0)
            {
                clonemesh.normals = mod.norms;                  //mesh.normals;
            }
            else
            {
                clonemesh.normals = mesh.normals;
            }

            clonemesh.tangents = mesh.tangents;
            clonemesh.colors   = mesh.colors;

            clonemesh.subMeshCount = mesh.subMeshCount;

            for (int s = 0; s < mesh.subMeshCount; s++)
            {
                clonemesh.SetTriangles(mesh.GetTriangles(s), s);
            }

            CopyBlendShapes(mesh, clonemesh);

            clonemesh.boneWeights = mesh.boneWeights;
            clonemesh.bindposes   = mesh.bindposes;
            clonemesh.name        = mesh.name + "_copy";
            clonemesh.RecalculateBounds();

            newmf.sharedMesh = clonemesh;

            for (int j = 0; j < mcs.Length; j++)
            {
                MeshCollider mc = mcs[j];
                if (mc.sharedMesh == mesh)
                {
                    clonemcs[j].sharedMesh = clonemesh;
                }
            }

            if (newsmr && oldsmr)
            {
                newsmr.sharedMesh = clonemesh;
#if UNITY_5_3 || UNITY_5_4 || UNITY_5_5 || UNITY_5_6 || UNITY_2017
                for (int b = 0; b < mesh.blendShapeCount; b++)
                {
                    newsmr.SetBlendShapeWeight(b, oldsmr.GetBlendShapeWeight(b));
                }
#endif
            }
        }

        return(clone);
    }
 /**
  * Set the fish's blend shape weights
  *
  * @param genome FishGenome The genome that will determine how the blend shape weights are set
  */
 private void setBlendWeights(FishGenome genome)
 {
     blendRenderer.SetBlendShapeWeight(0, Random.Range(0f, 100f));
 }
Ejemplo n.º 22
0
        public BlendShapeMerger(IEnumerable <BlendShapeClip> clips, Transform root)
        {
            m_materialMap = new Dictionary <string, Material>();
            foreach (var x in root.Traverse())
            {
                var renderer = x.GetComponent <Renderer>();
                if (renderer != null)
                {
                    foreach (var y in renderer.sharedMaterials.Where(y => y != null))
                    {
                        if (!string.IsNullOrEmpty(y.name))
                        {
                            if (!m_materialMap.ContainsKey(y.name))
                            {
                                m_materialMap.Add(y.name, y);
                            }
                        }
                    }
                }
            }

            m_clipMap = clips.ToDictionary(x => BlendShapeKey.CreateFrom(x), x => x);

            m_valueMap = new Dictionary <BlendShapeKey, float>();

            foreach (var kv in m_clipMap)
            {
                foreach (var binding in kv.Value.Values)
                {
                    if (!m_blendShapeSetterMap.ContainsKey(binding))
                    {
                        var _target = root.Find(binding.RelativePath);
                        SkinnedMeshRenderer target = null;
                        if (_target != null)
                        {
                            target = _target.GetComponent <SkinnedMeshRenderer>();
                        }
                        if (target != null)
                        {
                            m_blendShapeSetterMap.Add(binding, x =>
                            {
                                target.SetBlendShapeWeight(binding.Index, x);
                            });
                        }
                        else
                        {
                            Debug.LogWarningFormat("SkinnedMeshRenderer: {0} not found", binding.RelativePath);
                        }
                    }
                }

                foreach (var binding in kv.Value.MaterialValues)
                {
                    if (!m_materialSetterMap.ContainsKey(binding))
                    {
                        Material target;
                        if (m_materialMap.TryGetValue(binding.MaterialName, out target))
                        {
                            m_materialSetterMap.Add(binding, x =>
                            {
                                //target.SetBlendShapeWeight(binding.Index, x);
                                var propValue = binding.BaseValue + (binding.TargetValue - binding.BaseValue) * x;
                                target.SetColor(binding.ValueName, propValue);
                            });
                        }
                        else
                        {
                            Debug.LogWarningFormat("material: {0} not found", binding.MaterialName);
                        }
                    }
                }
            }
        }
Ejemplo n.º 23
0
 /// <summary>
 /// Handles events from <see cref="BlendShapeControl"/>.
 /// </summary>
 /// <param name="skinnedMeshRenderer">Skinned Mesh Renderer to set the blend shape.</param>
 /// <param name="index">Blend Shape index.</param>
 /// <param name="value">Blend Shape value.</param>
 public void HandleBlendEvent(SkinnedMeshRenderer skinnedMeshRenderer, int index, float value)
 {
     skinnedMeshRenderer.SetBlendShapeWeight(index, value);
 }
Ejemplo n.º 24
0
    //in succession
    private void setBlendShapes()
    {
        double[] ArrayOfDouble = new double[140];
        double[] skinn         = new double[50] {
            0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0
        };

        if (getdetection_success() == 1)
        {
            // Mouth & Eye Brow Animation

            // ArrayOfDouble de 0 --> 135 !=0 | 136 --> 140 = 0

            IntPtr p2DDoubleArray = IntPtr.Zero;
            getXY(out p2DDoubleArray);
            Marshal.Copy(p2DDoubleArray, ArrayOfDouble, 0, 140);

            skinn[35] = Math.Abs(ArrayOfDouble[51] - ArrayOfDouble[57]) * 10;


            /*
             * Debug.Log(" 0 : " + ArrayOfDouble[0]);
             * Debug.Log(" 100 : " + ArrayOfDouble[100]);
             * Debug.Log(" 135 : " + ArrayOfDouble[135]);
             */

            //--> this will give exception don't try it
            //Debug.Log(" 136 : " + ArrayOfDouble[136]);

            // We have 68 ponint of X and 68 point of X but blendShapeCount = 50
            // do some math here to get 50 point

            /**
             *
             *   MATHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHHH
             *
             *
             */

            blendShapeCount = skinnedMesh.blendShapeCount;
            for (int i = 0; i < blendShapeCount; i++)
            {
                skinnedMeshRenderer.SetBlendShapeWeight(i, (float)skinn[i]);
            }

            // Face Pose Animation

            hr = new Vector3(Mathf.Rad2Deg * get_pose1(), Mathf.Rad2Deg * get_pose2(), Mathf.Rad2Deg * get_pose3());
        }
        else
        {
            hr = new Vector3(0, 0, 0);
        }
        head.rotation = Quaternion.Euler(hr);

        // Eye Look At Animation

        ltarget.localPosition = new Vector3(-1 * (get_gaze1() - 0.13f), get_gaze2() - 0.1f, get_gaze3() * -1);
        rtarget.localPosition = new Vector3(-1 * (get_gaze4() + 0.13f), get_gaze5() - 0.1f, get_gaze6() * -1);
        lefteye.LookAt(ltarget);
        righteye.LookAt(rtarget);
    }
Ejemplo n.º 25
0
        /// <summary>
        /// Perform the blendshape changes in LateUpdate for mechanim compatibility
        /// </summary>
        void LateUpdate()
        {
            // Sync SALSA shapes
            if (salsa3D && body && lockShapes)
            {
                for (int i = 0; i < saySmall.Count; i++)
                {
                    body.SetBlendShapeWeight(
                        saySmall[i].shapeIndex, ((saySmall[i].percentage / 100) * salsa3D.sayAmount.saySmall));
                }
                for (int i = 0; i < sayMedium.Count; i++)
                {
                    body.SetBlendShapeWeight(
                        sayMedium[i].shapeIndex, ((sayMedium[i].percentage / 100) * salsa3D.sayAmount.sayMedium));
                }
                for (int i = 0; i < sayLarge.Count; i++)
                {
                    body.SetBlendShapeWeight(
                        sayLarge[i].shapeIndex, ((sayLarge[i].percentage / 100) * salsa3D.sayAmount.sayLarge));
                }
            }

            // Toggle shape lock to provide access to shape group shapes when SALSA is not talking
            if (salsa3D)
            {
                if (salsa3D.sayAmount.saySmall == 0f && salsa3D.sayAmount.sayMedium == 0f && salsa3D.sayAmount.sayLarge == 0f)
                {
                    lockShapes = false;
                }
                else
                {
                    lockShapes = true;
                }
            }

            // Sync blink, eye movement, and custom shapes
            if (randomEyes3D)
            {
                // Sync custom shape weights to all other SkinnedMeshRenderers
                for (int i = 0; i < body.sharedMesh.blendShapeCount; i++)
                {
                    srcShapeWeight = body.GetBlendShapeWeight(i);

                    if (eyelashes)
                    {
                        if (i < eyelashes.sharedMesh.blendShapeCount)
                        {
                            eyelashes.SetBlendShapeWeight(i, srcShapeWeight);
                        }
                    }

                    if (facialHair.Count > 0)
                    {
                        for (int fh = 0; fh < facialHair.Count; fh++)
                        {
                            if (srcShapeWeight > 0)
                            {
                                syncIndex = -1;
                                syncIndex = ShapeSearch(facialHair[fh], body.sharedMesh.GetBlendShapeName(i).Split(new char[] { '.' })[1]);
                                if (syncIndex != -1)
                                {
                                    facialHair[fh].SetBlendShapeWeight(syncIndex, srcShapeWeight);
                                }
                            }
                        }
                    }
                }

                blinkWeight = randomEyes3D.lookAmount.blink;

                // Apply blink action on eye lids
                if (body)
                {
                    if (leftEyelidIndex == -1)
                    {
                        leftEyelidIndex = ShapeSearch(body, blinkLeftShape);
                    }
                    if (rightEyelidIndex == -1)
                    {
                        rightEyelidIndex = ShapeSearch(body, blinkRightShape);
                    }

                    if (leftEyelidIndex != -1)
                    {
                        body.SetBlendShapeWeight(leftEyelidIndex, blinkWeight);
                    }
                    if (rightEyelidIndex != -1)
                    {
                        body.SetBlendShapeWeight(rightEyelidIndex, blinkWeight);
                    }
                }

                // Apply look amount to bone rotation
                if (leftEyeBone || rightEyeBone)
                {
                    // Apply eye movement weight direction variables
                    if (randomEyes3D.lookAmount.lookUp > 0)
                    {
                        vertical = -(randomEyes3D.lookAmount.lookUp / eyeSensativity) * randomEyes3D.rangeOfMotion;
                    }
                    if (randomEyes3D.lookAmount.lookDown > 0)
                    {
                        vertical = (randomEyes3D.lookAmount.lookDown / eyeSensativity) * randomEyes3D.rangeOfMotion;
                    }
                    if (randomEyes3D.lookAmount.lookLeft > 0)
                    {
                        horizontal = -(randomEyes3D.lookAmount.lookLeft / eyeSensativity) * randomEyes3D.rangeOfMotion;
                    }
                    if (randomEyes3D.lookAmount.lookRight > 0)
                    {
                        horizontal = (randomEyes3D.lookAmount.lookRight / eyeSensativity) * randomEyes3D.rangeOfMotion;
                    }

                    // Set eye bone rotations
                    if (leftEyeBone)
                    {
                        leftEyeBone.transform.localRotation = Quaternion.Euler(vertical, horizontal, 0);
                    }
                    if (rightEyeBone)
                    {
                        rightEyeBone.transform.localRotation = Quaternion.Euler(vertical, horizontal, 0);
                    }
                }
            }
        }
Ejemplo n.º 26
0
    // Update is called once per frame
    void Update()
    {
        foreach (Outline o in outlines)
        {
            outlinesDict[o] = false;
        }
        if (Input.GetKeyDown(KeyCode.E))
        {
            doPick = true;
        }
        RaycastHit hit;
        Ray        ray = Camera.main.ScreenPointToRay(new Vector3(Screen.width * 0.5f, Screen.height * 0.5f));

        // Does the ray intersect any objects excluding the player layer
        if (Physics.Raycast(ray, out hit, 2f))
        {
            if (hit.transform.tag == "TimeInteractable" || hit.transform.tag == "Pickupable")
            {
                Outline o = hit.transform.GetComponent <Outline>();
                if (!outlines.Contains(o))
                {
                    outlines.Add(o);
                }
                outlinesDict[o] = true;

                if (hit.transform.tag == "TimeInteractable")
                {
                    TimeContainer tc = hit.transform.gameObject.GetComponent <TimeContainer>();

                    if (Input.GetMouseButton(0))
                    {
                        if (Input.GetMouseButtonDown(0))
                        {
                            timeSound.Play();
                        }

                        GetComponent <TimePower>().DrainObject(tc);

                        SkinnedMeshRenderer r = hit.transform.GetComponentInChildren <SkinnedMeshRenderer>();
                        if (r != null)
                        {
                            r.SetBlendShapeWeight(0, (1f - tc.currentTime / tc.GetMaxTime()) * 100f);
                        }

                        if (tc.currentTime == 0f)
                        {
                            if (timeSound.isPlaying())
                            {
                                timeSound.Stop();
                            }
                        }
                        takeParticles.gameObject.SetActive(tc.currentTime > 0f);
                        giveParticles.gameObject.SetActive(false);

                        //float weight = r.GetBlendShapeWeight(0);
                        //weight = Mathf.Min(weight + blendShapeChangeSpeed * Time.deltaTime, 100f);
                        //r.SetBlendShapeWeight(0, weight);
                    }
                    else if (Input.GetMouseButton(1))
                    {
                        if (Input.GetMouseButtonDown(1))
                        {
                            timeSound.Play();
                        }
                        GetComponent <TimePower>().RestoreObject(tc);

                        SkinnedMeshRenderer r = hit.transform.GetComponentInChildren <SkinnedMeshRenderer>();
                        if (r != null)
                        {
                            r.SetBlendShapeWeight(0, (1f - tc.currentTime / tc.GetMaxTime()) * 100f);
                        }
                        //float weight = r.GetBlendShapeWeight(0);
                        //weight = Mathf.Max(weight - blendShapeChangeSpeed * Time.deltaTime, 0f);
                        //r.SetBlendShapeWeight(0, weight);

                        if (tc.currentTime == tc.GetMaxTime())
                        {
                            if (timeSound.isPlaying())
                            {
                                timeSound.Stop();
                            }
                        }
                        giveParticles.gameObject.SetActive(tc.currentTime < tc.GetMaxTime());
                        takeParticles.gameObject.SetActive(false);
                    }
                    else
                    {
                        stopTimeEffect();
                    }

                    o.OutlineColor = Color.Lerp(lowTimeColor, highTimeColor, tc.currentTime / tc.GetMaxTime());
                }
                else
                {
                    stopTimeEffect();
                    if (hit.transform.tag == "Pickupable")
                    {
                        if (doPick && pickedUp == false)
                        {
                            pickup = hit.transform.gameObject.GetComponent <Pickup>();
                            pickup.TogglePickup(physicsFollowTarget);
                            pickedUp = true;
                            doPick   = false;
                        }
                    }
                }
            }
        }
        else
        {
            stopTimeEffect();
        }

        if (doPick && pickedUp == true)
        {
            pickup.TogglePickup(physicsFollowTarget);
            pickedUp = false;
            doPick   = false;
        }
        foreach (Outline o in outlines)
        {
            o.enabled = outlinesDict[o];
        }
        doPick = false;
    }
Ejemplo n.º 27
0
 void SetCloseEyes()
 {
     ref_SMR_EYE_DEF.SetBlendShapeWeight(6, ratio_Close);
     ref_SMR_EL_DEF.SetBlendShapeWeight(6, ratio_Close);
 }
Ejemplo n.º 28
0
 private void Update()
 {
     amount = Input.GetAxis("Vertical") * 100;
     m_skinMesh.SetBlendShapeWeight(0, amount);
 }
Ejemplo n.º 29
0
 /**
  * <summary>Sets the value of the associated blendshape</summary>
  * <param name = "_value">The value that the blendshape should have</param>
  * <param name = "smr">The SkinnedMeshRenderer component that the blendshape is a part of</param>
  */
 public void SetValue(float _value, SkinnedMeshRenderer smr)
 {
     value = _value;
     smr.SetBlendShapeWeight(index, value);
 }
Ejemplo n.º 30
0
    void SetFacial()
    {
        //Override the Animator
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(0, _SapphiArtChanFacial_Eye_L_Happy);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(1, _SapphiArtChanFacial_Eye_R_Happy);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(4, _SapphiArtChanFacial_Eye_L_Closed);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(5, _SapphiArtChanFacial_Eye_R_Closed);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(2, _SapphiArtChanFacial_Eye_L_Wide);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(3, _SapphiArtChanFacial_Eye_R_Wide);

        _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(0, _SapphiArtChanFacial_Eyebrow_L_Up);
        _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(1, _SapphiArtChanFacial_Eyebrow_R_Up);
        _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(2, _SapphiArtChanFacial_Eyebrow_L_Angry);
        _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(3, _SapphiArtChanFacial_Eyebrow_R_Angry);
        _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(4, _SapphiArtChanFacial_Eyebrow_L_Sad);
        _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(5, _SapphiArtChanFacial_Eyebrow_R_Sad);

        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(6, _SapphiArtChanFacial_Mouth_E);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(8, _SapphiArtChanFacial_Mouth_O);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(7, _SapphiArtChanFacial_Mouth_JawOpen);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(12, _SapphiArtChanFacial_Mouth_Extra01);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(13, _SapphiArtChanFacial_Mouth_Extra02);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(14, _SapphiArtChanFacial_Mouth_Extra03);

        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(9, _SapphiArtChanFacial_Mouth_Sad);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(10, _SapphiArtChanFacial_Mouth_Puff);
        _SapphiArtChanRenderer_Face.SetBlendShapeWeight(11, _SapphiArtChanFacial_Mouth_Smile);

        if (_SapphiArtChanRenderer_BottomTeeth.isVisible)
        {
            _SapphiArtChanRenderer_BottomTeeth.SetBlendShapeWeight(0, _SapphiArtChanFacial_Mouth_BottomTeeth);
        }



        string _GeneralChangeType = _AnimationManagerUI._GeneralChangeType;

        _SapphiArtChanLastFacial     = _SapphiArtChanFacial;
        _SapphiArtChanFacial         = _AnimationManagerUI._FacialValue;
        _SapphiArtChanLastFacialBool = _SapphiArtChanFacialBool;
        _SapphiArtChanFacialBool     = _AnimationManagerUI._FacialValueBool;

        if (_GeneralChangeType == null)
        {
            return;
        }

        else if (_GeneralChangeType == "eyes")
        {
            string _EyesChangeType = _AnimationManagerUI._EyesChangeType;
            if (_EyesChangeType == null)
            {
                return;
            }

            if (_EyesChangeType == _EyesLastChangeType && _SapphiArtChanFacial == _SapphiArtChanLastFacial)
            {
                return;
            }

            else if (_EyesChangeType == "happyL")
            {
                _EyesLastChangeType = _EyesChangeType;
                _SapphiArtChanFacial_Eye_L_Happy = _SapphiArtChanFacial;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(0, _SapphiArtChanFacial);
            }
            else if (_EyesChangeType == "happyR")
            {
                _EyesLastChangeType = _EyesChangeType;
                _SapphiArtChanFacial_Eye_R_Happy = _SapphiArtChanFacial;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(1, _SapphiArtChanFacial);
            }
            else if (_EyesChangeType == "closedL")
            {
                _SapphiArtChanFacial_Eye_L_Closed = _SapphiArtChanFacial;
                _EyesLastChangeType = _EyesChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(4, _SapphiArtChanFacial);
            }
            else if (_EyesChangeType == "closedR")
            {
                _SapphiArtChanFacial_Eye_R_Closed = _SapphiArtChanFacial;
                _EyesLastChangeType = _EyesChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(5, _SapphiArtChanFacial);
            }
            else if (_EyesChangeType == "wideL")
            {
                _SapphiArtChanFacial_Eye_L_Wide = _SapphiArtChanFacial;
                _EyesLastChangeType             = _EyesChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(2, _SapphiArtChanFacial);
            }
            else if (_EyesChangeType == "wideR")
            {
                _SapphiArtChanFacial_Eye_R_Wide = _SapphiArtChanFacial;
                _EyesLastChangeType             = _EyesChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(3, _SapphiArtChanFacial);
            }
        }



        else if (_GeneralChangeType == "eyebrows")
        {
            string _EyebrowsChangeType = _AnimationManagerUI._EyebrowsChangeType;
            if (_EyebrowsChangeType == null)
            {
                return;
            }

            if (_EyebrowsChangeType == _EyebrowsLastChangeType && _SapphiArtChanFacial == _SapphiArtChanLastFacial)
            {
                return;
            }

            else if (_EyebrowsChangeType == "upL")
            {
                _SapphiArtChanFacial_Eyebrow_L_Up = _SapphiArtChanFacial;
                _EyebrowsLastChangeType           = _EyebrowsChangeType;
                _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(0, _SapphiArtChanFacial);
            }

            else if (_EyebrowsChangeType == "upR")
            {
                _SapphiArtChanFacial_Eyebrow_R_Up = _SapphiArtChanFacial;
                _EyebrowsLastChangeType           = _EyebrowsChangeType;
                _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(1, _SapphiArtChanFacial);
            }

            else if (_EyebrowsChangeType == "angerL")
            {
                _SapphiArtChanFacial_Eyebrow_L_Angry = _SapphiArtChanFacial;
                _EyebrowsLastChangeType = _EyebrowsChangeType;
                _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(2, _SapphiArtChanFacial);
            }

            else if (_EyebrowsChangeType == "angerR")
            {
                _SapphiArtChanFacial_Eyebrow_R_Angry = _SapphiArtChanFacial;
                _EyebrowsLastChangeType = _EyebrowsChangeType;
                _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(3, _SapphiArtChanFacial);
            }

            else if (_EyebrowsChangeType == "sadL")
            {
                _SapphiArtChanFacial_Eyebrow_L_Sad = _SapphiArtChanFacial;
                _EyebrowsLastChangeType            = _EyebrowsChangeType;
                _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(4, _SapphiArtChanFacial);
            }

            else if (_EyebrowsChangeType == "sadR")
            {
                _SapphiArtChanFacial_Eyebrow_R_Sad = _SapphiArtChanFacial;
                _EyebrowsLastChangeType            = _EyebrowsChangeType;
                _SapphiArtChanRenderer_Brow.SetBlendShapeWeight(5, _SapphiArtChanFacial);
            }
        }

        else if (_GeneralChangeType == "mouth")
        {
            string _MouthChangeType = _AnimationManagerUI._MouthChangeType;
            if (_MouthChangeType == null)
            {
                return;
            }

            if (_MouthChangeType == _MouthLastChangeType &&
                _SapphiArtChanFacial == _SapphiArtChanLastFacial &&
                _SapphiArtChanFacialBool == _SapphiArtChanLastFacialBool)
            {
                return;
            }

            else if (_MouthChangeType == "mouthE")
            {
                _SapphiArtChanFacial_Mouth_E = _SapphiArtChanFacial;
                _MouthLastChangeType         = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(6, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthO")
            {
                _SapphiArtChanFacial_Mouth_O = _SapphiArtChanFacial;
                _MouthLastChangeType         = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(8, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthJawOpen")
            {
                _SapphiArtChanFacial_Mouth_JawOpen = _SapphiArtChanFacial;
                _MouthLastChangeType = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(7, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthExtra01")
            {
                _SapphiArtChanFacial_Mouth_Extra01 = _SapphiArtChanFacial;
                _MouthLastChangeType = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(12, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthExtra02")
            {
                _SapphiArtChanFacial_Mouth_Extra02 = _SapphiArtChanFacial;
                _MouthLastChangeType = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(13, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthExtra03")
            {
                _SapphiArtChanFacial_Mouth_Extra03 = _SapphiArtChanFacial;
                _MouthLastChangeType = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(14, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "sad")
            {
                _SapphiArtChanFacial_Mouth_Sad = _SapphiArtChanFacial;
                _MouthLastChangeType           = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(9, _SapphiArtChanFacial);
            }
            else if (_MouthChangeType == "puff")
            {
                _SapphiArtChanFacial_Mouth_Puff = _SapphiArtChanFacial;
                _MouthLastChangeType            = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(10, _SapphiArtChanFacial);
            }
            else if (_MouthChangeType == "smile")
            {
                _SapphiArtChanFacial_Mouth_Smile = _SapphiArtChanFacial;
                _MouthLastChangeType             = _MouthChangeType;
                _SapphiArtChanRenderer_Face.SetBlendShapeWeight(11, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthBottomTeeth")
            {
                _SapphiArtChanFacial_Mouth_BottomTeeth = _SapphiArtChanFacial;
                _MouthLastChangeType = _MouthChangeType;
                _SapphiArtChanRenderer_BottomTeeth.SetBlendShapeWeight(0, _SapphiArtChanFacial);
            }

            else if (_MouthChangeType == "mouthTopTeeth")
            {
                _SapphiArtChanFacial_Mouth_TopTeeth = _SapphiArtChanFacialBool;
                Debug.Log(_SapphiArtChanFacialBool);
                _MouthLastChangeType = _MouthChangeType;
                if (_SapphiArtChanFacialBool == false)
                {
                    _SapphiArtChanRenderer_TopTeeth.enabled = _SapphiArtChanFacialBool;
                }
                else
                {
                    _SapphiArtChanRenderer_TopTeeth.enabled = true;
                }
            }

            else if (_MouthChangeType == "mouthTongue")
            {
                _SapphiArtChanFacial_Mouth_Tongue = _SapphiArtChanFacialBool;
                _MouthLastChangeType = _MouthChangeType;
                if (_SapphiArtChanFacialBool == false)
                {
                    _SapphiArtChanRenderer_Tongue.enabled = _SapphiArtChanFacialBool;
                }
                else
                {
                    _SapphiArtChanRenderer_Tongue.enabled = true;
                }
            }
        }
    }