Ejemplo n.º 1
0
 // Token: 0x060043FE RID: 17406 RVA: 0x00167BE8 File Offset: 0x00165FE8
 public void RestoreDefault(ControlData.EyelidBoneMode eyelidBoneMode)
 {
     if (eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Rotation)
     {
         this.transform.localRotation = this.defaultQ;
     }
     if ((eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Position) && this.isDefaultPosSet)
     {
         this.transform.localPosition = this.defaultPos;
     }
 }
Ejemplo n.º 2
0
 // Token: 0x06004400 RID: 17408 RVA: 0x00167C90 File Offset: 0x00166090
 public void RestoreLookUp(ControlData.EyelidBoneMode eyelidBoneMode)
 {
     if (eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Rotation)
     {
         this.transform.localRotation = this.lookUpQ;
     }
     if ((eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Position) && this.isLookUpPosSet)
     {
         this.transform.localPosition = this.lookUpPos;
     }
 }
Ejemplo n.º 3
0
 // Token: 0x060043FD RID: 17405 RVA: 0x00167B94 File Offset: 0x00165F94
 public void RestoreClosed(ControlData.EyelidBoneMode eyelidBoneMode)
 {
     if (eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Rotation)
     {
         this.transform.localRotation = this.closedQ;
     }
     if ((eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Position) && this.isClosedPosSet)
     {
         this.transform.localPosition = this.closedPos;
     }
 }
        void DrawControlData(EyeAndHeadAnimator eyeAndHeadAnimator)
        {
            if ( redTextStyle == null )
                redTextStyle = new GUIStyle (GUI.skin.label) {normal = {textColor = Color.red}};

            ControlData controlData = eyeAndHeadAnimator.controlData;

            EditorGUI.indentLevel = 0;

            //*** Combobox for eye control
            {
                eyeControl = controlData.eyeControl;
                int selectedIndex = EditorGUILayout.Popup ("Eye control", (int) eyeControl, eyeControlStringList);
                eyeControl = controlData.eyeControl = (ControlData.EyeControl) selectedIndex;
            }

            //*** For eyeball control, slots to assign eye objects
            {
                if ( eyeControl == ControlData.EyeControl.SelectedObjects )
                {
                    controlData.leftEye = EditorGUILayout.ObjectField("Left eye", controlData.leftEye, typeof(Transform), true ) as Transform;
                    controlData.rightEye = EditorGUILayout.ObjectField("Right eye", controlData.rightEye, typeof(Transform), true ) as Transform;
                }
            }

            //*** bools for eye control
            bool isEyeballControl = eyeControl == ControlData.EyeControl.SelectedObjects;
            bool isEyeBoneControl = eyeControl == ControlData.EyeControl.MecanimEyeBones;

            if ( isEyeBoneControl && false == eyeAndHeadAnimator.gameObject.activeSelf )
            {
                EditorGUILayout.LabelField("Gameobject inactive; activate to show controls.");

                return; // prevent missing animator error message, because the animator cannot be found on a non-active gameobject
            }
            if ( isEyeBoneControl && animator == null )
                animator = eyeAndHeadAnimator.GetComponent<Animator>();
            bool isAnimatorMissing = isEyeBoneControl && animator == null;
            bool areEyeTransformsMissing = isEyeballControl && ( controlData.leftEye == null || controlData.rightEye == null );
            bool areEyeBonesMissing = isEyeBoneControl && animator != null &&
                                                        (null == animator.GetBoneTransform(HumanBodyBones.LeftEye) || null == animator.GetBoneTransform(HumanBodyBones.LeftEye) );

            //*** Error message if any data for eye control is missing
            {
                if ( isEyeBoneControl || isEyeballControl )
                {
                    if ( areEyeTransformsMissing )
                        EditorGUILayout.LabelField("The eyeballs need to be assigned.", redTextStyle);

                    if ( isAnimatorMissing )
                        EditorGUILayout.LabelField("No Animator found.", redTextStyle);

                    if ( areEyeBonesMissing )
                        EditorGUILayout.LabelField("Eye bones not found; is the Mecanim rig set up correctly?", redTextStyle);

                    if ( areEyeTransformsMissing || isAnimatorMissing || areEyeBonesMissing )
                    {
                        return;
                    }
                }
                else
                {
                    return;
                }
            }

            //*** Combobox for eyelid control
            {
                eyelidControl = controlData.eyelidControl;
                int selectedIndex = EditorGUILayout.Popup ("Eyelid control", (int) eyelidControl, eyelidControlStringList);
                eyelidControl = controlData.eyelidControl = (ControlData.EyelidControl) selectedIndex;
            }

            //*** Eyelid bone control: assign transforms for the four bones
            {
                if ( eyelidControl == ControlData.EyelidControl.Bones )
                {
                    controlData.upperEyeLidLeft = EditorGUILayout.ObjectField("Upper left eyelid", controlData.upperEyeLidLeft, typeof(Transform), true ) as Transform;
                    controlData.lowerEyeLidLeft = EditorGUILayout.ObjectField("Lower left eyelid", controlData.lowerEyeLidLeft, typeof(Transform), true ) as Transform;
                    controlData.upperEyeLidRight = EditorGUILayout.ObjectField("Upper right eyelid", controlData.upperEyeLidRight, typeof(Transform), true ) as Transform;
                    controlData.lowerEyeLidRight = EditorGUILayout.ObjectField("Lower right eyelid", controlData.lowerEyeLidRight, typeof(Transform), true ) as Transform;
                }
            }

            //*** bools for eyelid control
            bool isEyelidBoneControl = eyelidControl == ControlData.EyelidControl.Bones;
            bool isEyelidBlendshapeControl = eyelidControl == ControlData.EyelidControl.Blendshapes;
            bool areEyelidTransformsMissing = isEyelidBoneControl && (controlData.upperEyeLidLeft == null || controlData.upperEyeLidRight == null );

            //*** Error message if eyelid transforms are missing
            {
                if ( areEyelidTransformsMissing )
                {
                    EditorGUILayout.LabelField("At least the upper eyelid bones need to be assigned", redTextStyle);

                    return;
                }
            }

            //*** Error message if only one of the lower eyelids is assigned
            {
                if ( isEyelidBoneControl && ((controlData.lowerEyeLidLeft == null) != (controlData.lowerEyeLidRight == null) ))
                {
                    EditorGUILayout.LabelField("Only one of the lower eyelid bones is assigned", redTextStyle);

                    return;
                }
            }

            //*** Error message if an eyelid bone is assigned twice
            {
                if ( eyelidControl == ControlData.EyelidControl.Bones )
                {
                    if ( controlData.upperEyeLidLeft != null && controlData.upperEyeLidLeft == controlData.upperEyeLidRight )
                    {
                        EditorGUILayout.LabelField("Upper Left eyelid bone cannot be the same as Upper Right", redTextStyle);
                        return;
                    }
                    if ( controlData.upperEyeLidLeft != null && controlData.upperEyeLidLeft == controlData.lowerEyeLidLeft )
                    {
                        EditorGUILayout.LabelField("Upper Left eyelid bone cannot be the same as Lower Left", redTextStyle);
                        return;
                    }
                    if ( controlData.upperEyeLidLeft != null && controlData.upperEyeLidLeft == controlData.lowerEyeLidRight )
                    {
                        EditorGUILayout.LabelField("Upper Left eyelid bone cannot be the same as Lower Right", redTextStyle);
                        return;
                    }

                    if ( controlData.upperEyeLidRight != null && controlData.upperEyeLidRight == controlData.lowerEyeLidLeft )
                    {
                        EditorGUILayout.LabelField("Upper Right eyelid bone cannot be the same as Lower Left", redTextStyle);
                        return;
                    }
                    if ( controlData.upperEyeLidRight != null && controlData.upperEyeLidRight == controlData.lowerEyeLidRight )
                    {
                        EditorGUILayout.LabelField("Upper Right eyelid bone cannot be the same as Lower Right", redTextStyle);
                        return;
                    }

                    if ( controlData.lowerEyeLidLeft != null && controlData.lowerEyeLidLeft == controlData.lowerEyeLidRight )
                    {
                        EditorGUILayout.LabelField("Lower Left eyelid bone cannot be the same as Lower Right", redTextStyle);
                        return;
                    }
                }
            }

            //*** Combobox for eyelid bone mode (RotationAndPosition, Rotation, or Position)
            {
                if ( eyelidControl == ControlData.EyelidControl.Bones )
                {
                    eyelidBoneMode = controlData.eyelidBoneMode;
                    int selectedIndex = EditorGUILayout.Popup ("Eyelid bone mode", (int) eyelidBoneMode, eyelidBoneModeStringList);
                    eyelidBoneMode = controlData.eyelidBoneMode = (ControlData.EyelidBoneMode) selectedIndex;
                }
            }

            bool isDefaultSet = false;
            bool isClosedSet = false;
            bool isLookUpSet = false;
            bool isLookDownSet = false;

            //*** Default eye opening
            {
                if ( isEyeBoneControl || isEyeballControl )
                {
                    EditorGUILayout.BeginHorizontal();
                        EditorGUILayout.LabelField("Eyes open, looking straight");
                        if ( GUILayout.Button("Save") )
                            controlData.SaveDefault( eyeAndHeadAnimator );

                        isDefaultSet = true;
                        if ( isEyeballControl )
                            isDefaultSet &= controlData.isEyeBallDefaultSet;
                        if ( isEyeBoneControl )
                            isDefaultSet &= controlData.isEyeBoneDefaultSet;
                        if ( isEyelidBoneControl )
                            isDefaultSet &= controlData.isEyelidBonesDefaultSet;
                        if ( isEyelidBlendshapeControl )
                            isDefaultSet &= controlData.isEyelidBlendshapeDefaultSet;

                        if ( isDefaultSet )
                        {
                            if ( GUILayout.Button( "Load") )
                                controlData.RestoreDefault();
                        }
                        else
                            EditorGUILayout.LabelField( "Not saved yet", redTextStyle);
                    EditorGUILayout.EndHorizontal();
                }
            }

            if ( isDefaultSet )
            {
                //*** Closed
                {
                    if ( isEyelidBoneControl || isEyelidBlendshapeControl )
                    {
                        EditorGUILayout.BeginHorizontal();
                            EditorGUILayout.LabelField("Eyes closed, looking straight");
                            if ( GUILayout.Button("Save") )
                                controlData.SaveClosed( eyeAndHeadAnimator );

                            isClosedSet = true;
                            if ( isEyelidBoneControl )
                                isClosedSet &= controlData.isEyelidBonesClosedSet;
                            if ( isEyelidBlendshapeControl )
                                isClosedSet &= controlData.isEyelidBlendshapeClosedSet;

                            if ( isClosedSet )
                            {
                                if ( GUILayout.Button("Load") )
                                    controlData.RestoreClosed();
                            }
                            else
                                EditorGUILayout.LabelField("Not saved yet", redTextStyle);
                        EditorGUILayout.EndHorizontal();
                    }
                }

                //*** Looking up
                {
                    EditorGUILayout.BeginHorizontal();

                                string tooltip = "Rotate " + (isEyeBoneControl ? "eyebones" : "eyes") + " to look up maximally";
                                if ( isEyelidBoneControl || isEyelidBlendshapeControl )
                                    tooltip += ", and adjust eyelid " + (isEyelidBoneControl ? "bone rotation" : "blendshapes") + " for that position";
                        EditorGUILayout.LabelField(new GUIContent("Looking up", tooltip));
                        if ( GUILayout.Button("Save") )
                            controlData.SaveLookUp( eyeAndHeadAnimator );

                        isLookUpSet = true;
                        if ( isEyeballControl )
                            isLookUpSet &= controlData.isEyeBallLookUpSet;
                        if ( isEyeBoneControl )
                            isLookUpSet &= controlData.isEyeBoneLookUpSet;
                        if ( isEyelidBoneControl )
                            isLookUpSet &= controlData.isEyelidBonesLookUpSet;
                        if ( isEyelidBlendshapeControl )
                            isLookUpSet &= controlData.isEyelidBlendshapeLookUpSet;

                        if ( isLookUpSet )
                        {
                            if ( GUILayout.Button("Load") )
                                controlData.RestoreLookUp();
                        }
                        else
                            EditorGUILayout.LabelField("Not saved yet", redTextStyle);
                    EditorGUILayout.EndHorizontal();
                }

                //*** Looking down
                {
                    EditorGUILayout.BeginHorizontal();

                                string tooltip = "Rotate " + (isEyeBoneControl ? "eyebones" : "eyes") + " to look down maximally";
                                if ( isEyelidBoneControl || isEyelidBlendshapeControl )
                                    tooltip += ", and adjust eyelid " + (isEyelidBoneControl ? "bone rotation" : "blendshapes") + " for that position";
                        EditorGUILayout.LabelField(new GUIContent("Looking down", tooltip));
                        if ( GUILayout.Button("Save") )
                            controlData.SaveLookDown( eyeAndHeadAnimator );

                        isLookDownSet = true;
                        if ( isEyeballControl )
                            isLookDownSet &= controlData.isEyeBallLookDownSet;
                        if ( isEyeBoneControl )
                            isLookDownSet &= controlData.isEyeBoneLookDownSet;
                        if ( isEyelidBoneControl )
                            isLookDownSet &= controlData.isEyelidBonesLookDownSet;
                        if ( isEyelidBlendshapeControl )
                            isLookDownSet &= controlData.isEyelidBlendshapeLookDownSet;

                        if (isLookDownSet)
                        {
                            if (GUILayout.Button("Load"))
                                controlData.RestoreLookDown();
                        }
                        else
                            EditorGUILayout.LabelField("Not saved yet", redTextStyle);

                    EditorGUILayout.EndHorizontal();
                }
            }

            if (eyelidControl == ControlData.EyelidControl.Bones)
            {
                const string tooltip = "0: normal. 1: max widened, -1: max squint";
                controlData.eyeWidenOrSquint = EditorGUILayout.Slider(new GUIContent("Eye widen or squint", tooltip), controlData.eyeWidenOrSquint, -1, 1);
            }
        }
Ejemplo n.º 5
0
        // Token: 0x060043FB RID: 17403 RVA: 0x001678BC File Offset: 0x00165CBC
        public void GetRotationAndPosition(float eyeAngle, float blink01, float eyeWidenOrSquint, bool isUpper, out Quaternion rotation, ref Vector3 position, ControlData.EyelidBoneMode eyelidBoneMode)
        {
            bool  flag = eyeAngle > 0f;
            float t    = Mathf.InverseLerp(0f, (!flag) ? (-this.eyeMaxUpAngle) : this.eyeMaxDownAngle, eyeAngle);

            if (eyeWidenOrSquint < 0f)
            {
                blink01 = Mathf.Lerp(blink01, 1f, -eyeWidenOrSquint);
            }
            if (eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Rotation)
            {
                rotation = Quaternion.Slerp(this.defaultQ, (!flag) ? this.lookUpQ : this.lookDownQ, t);
                rotation = Quaternion.Slerp(rotation, this.closedQ, blink01);
                if (eyeWidenOrSquint > 0f)
                {
                    rotation = Quaternion.Slerp(rotation, (!isUpper) ? this.lookDownQ : this.lookUpQ, eyeWidenOrSquint);
                }
            }
            else
            {
                rotation = Quaternion.identity;
            }
            if (eyelidBoneMode == ControlData.EyelidBoneMode.RotationAndPosition || eyelidBoneMode == ControlData.EyelidBoneMode.Position)
            {
                if (flag)
                {
                    if (this.isDefaultPosSet && this.isLookDownPosSet)
                    {
                        position = Vector3.Lerp(this.defaultPos, this.lookDownPos, t);
                    }
                }
                else if (this.isDefaultPosSet && this.isLookUpPosSet)
                {
                    position = Vector3.Lerp(this.defaultPos, this.lookUpPos, t);
                }
                if (this.isDefaultPosSet && this.isClosedPosSet)
                {
                    position = Vector3.Lerp(position, this.closedPos, blink01);
                }
                if (eyeWidenOrSquint > 0f)
                {
                    position = Vector3.Lerp(position, (!isUpper) ? this.lookDownPos : this.lookUpPos, eyeWidenOrSquint);
                }
            }
        }