Ejemplo n.º 1
0
        /**
         * <summary>Creates a new instance of the 'Object: Blend shape' Action, set to disable all keys on a Shapeable</summary>
         * <param name = "shapeable">The Shapeable to manipulate</param>
         * <param name = "groupID">The ID of the group to affect</param>
         * <param name = "transitionTime">The time, in seconds, to take</param>
         * <param name = "waitUntilFinish">If True, then the Action will wait until the transition is complete</param>
         * <returns>The generated Action</returns>
         */
        public static ActionBlendShape CreateNew_DisableAllKeys(Shapeable shapeable, int groupID, float transitionTime = 0f, MoveMethod moveMethod = MoveMethod.Linear, AnimationCurve timeCurve = null)
        {
            ActionBlendShape newAction = (ActionBlendShape)CreateInstance <ActionBlendShape>();

            newAction.disableAllKeys = true;
            newAction.shapeObject    = shapeable;
            newAction.shapeGroupID   = groupID;
            newAction.fadeTime       = transitionTime;
            newAction.moveMethod     = moveMethod;
            newAction.timeCurve      = timeCurve;
            return(newAction);
        }
Ejemplo n.º 2
0
 public override void CharExpressionsGUI()
 {
                 #if UNITY_EDITOR
     if (character.useExpressions)
     {
         character.mapExpressionsToShapeable = CustomGUILayout.Toggle("Map to Shapeable?", character.mapExpressionsToShapeable, "", "If True, a Shapeable component can be mapped to expressions to allow for expression tokens to control blendshape");
         if (character.mapExpressionsToShapeable)
         {
             if (character.GetShapeable())
             {
                 character.expressionGroupID = ActionBlendShape.ShapeableGroupGUI("Expression shape group:", character.GetShapeable().shapeGroups, character.expressionGroupID);
                 EditorGUILayout.HelpBox("The names of the expressions below must match the shape key labels.", MessageType.Info);
             }
             else
             {
                 EditorGUILayout.HelpBox("A Shapeable component must be present on the model's Skinned Mesh Renderer.", MessageType.Warning);
             }
         }
     }
                 #endif
 }
Ejemplo n.º 3
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Standard 3D animations", EditorStyles.boldLabel);

            if (SceneSettings.IsTopDown())
            {
                character.spriteChild = (Transform)CustomGUILayout.ObjectField <Transform> ("Animation child:", character.spriteChild, true, "", "The child object that contains the Animation component");
            }
            else
            {
                character.spriteChild = null;
            }

            character.talkingAnimation = (TalkingAnimation)CustomGUILayout.EnumPopup("Talk animation style:", character.talkingAnimation, "", "How talking animations are handled");
            character.idleAnim         = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Idle:", character.idleAnim, false, "", "The 'Idle' animation");
            character.walkAnim         = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Walk:", character.walkAnim, false, "", "The 'Walk' animation");
            character.runAnim          = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Run:", character.runAnim, false, "", "The 'Run' animation");
            if (character.talkingAnimation == TalkingAnimation.Standard)
            {
                character.talkAnim = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Talk:", character.talkAnim, false, "", "The 'Talk' animation");
            }

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager)
            {
                if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                    AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
                {
                    if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                    {
                        if (character.GetShapeable())
                        {
                            character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("Attach a Shapeable script to show phoneme options", MessageType.Info);
                        }
                    }
                    else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                    {
                        if (character.GetComponent <LipSyncTexture>() == null)
                        {
                            EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                        }
                    }
                }
            }

            character.turnLeftAnim      = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Turn left:", character.turnLeftAnim, false, "", "The 'Turn left' animation");
            character.turnRightAnim     = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Turn right:", character.turnRightAnim, false, "", "The 'Turn right' animation");
            character.headLookLeftAnim  = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Head look left:", character.headLookLeftAnim, false, "", "The 'Look left' animation");
            character.headLookRightAnim = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Head look right:", character.headLookRightAnim, false, "", "The 'Look right' animation");
            character.headLookUpAnim    = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Head look up:", character.headLookUpAnim, false, "", "The 'Look up' animation");
            character.headLookDownAnim  = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Head look down:", character.headLookDownAnim, false, "", "The 'Look down' animation");

            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpAnim = (AnimationClip)CustomGUILayout.ObjectField <AnimationClip> ("Jump:", player.jumpAnim, false, "", "The 'Jump' animation");
            }
            EditorGUILayout.EndVertical();

            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms", EditorStyles.boldLabel);

            character.upperBodyBone = (Transform)CustomGUILayout.ObjectField <AnimationClip> ("Upper body:", character.upperBodyBone, true, "", "The 'Upper body bone' Transform, used to isolate animations");
            character.neckBone      = (Transform)CustomGUILayout.ObjectField <AnimationClip> ("Neck bone:", character.neckBone, true, "", "The 'Neck bone' Transform, used to isolate animations");
            character.leftArmBone   = (Transform)CustomGUILayout.ObjectField <AnimationClip> ("Left arm:", character.leftArmBone, true, "", "The 'Left arm bone' Transform, used to isolate animations");
            character.rightArmBone  = (Transform)CustomGUILayout.ObjectField <AnimationClip> ("Right arm:", character.rightArmBone, true, "", "The 'Right arm bone' Transform, used to isolate animations");
            character.leftHandBone  = (Transform)CustomGUILayout.ObjectField <AnimationClip> ("Left hand:", character.leftHandBone, true, "", "The 'Left hand bone' Transform, used to isolate animations");
            character.rightHandBone = (Transform)CustomGUILayout.ObjectField <AnimationClip> ("Right hand:", character.rightHandBone, true, "", "The 'Right hand bone' Transform, used to isolate animations");
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Ejemplo n.º 4
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

            character.moveSpeedParameter = EditorGUILayout.TextField("Move speed float:", character.moveSpeedParameter);
            character.turnParameter      = EditorGUILayout.TextField("Turn float:", character.turnParameter);
            character.talkParameter      = EditorGUILayout.TextField("Talk bool:", character.talkParameter);

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    if (character.GetShapeable())
                    {
                        character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                    }
                    else
                    {
                        EditorGUILayout.HelpBox("Attach a Shapeable script to show phoneme options", MessageType.Info);
                    }
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (!character.ikHeadTurning)
            {
                character.headYawParameter   = EditorGUILayout.TextField("Head yaw float:", character.headYawParameter);
                character.headPitchParameter = EditorGUILayout.TextField("Head pitch float:", character.headPitchParameter);
            }
            character.headTurnSpeed = EditorGUILayout.Slider("Head turn speed:", character.headTurnSpeed, 0.1f, 20f);

            character.verticalMovementParameter = EditorGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter);
            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpParameter = EditorGUILayout.TextField("Jump bool:", player.jumpParameter);
            }
            character.talkingAnimation = TalkingAnimation.Standard;

            if (character.useExpressions)
            {
                character.expressionParameter = EditorGUILayout.TextField("Expression ID integer:", character.expressionParameter);
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim settings:", EditorStyles.boldLabel);

            if (AdvGame.GetReferences() && AdvGame.GetReferences().settingsManager&& AdvGame.GetReferences().settingsManager.IsTopDown())
            {
                character.spriteChild = (Transform)EditorGUILayout.ObjectField("Animator child:", character.spriteChild, typeof(Transform), true);
            }
            else
            {
                character.spriteChild    = null;
                character.customAnimator = (Animator)EditorGUILayout.ObjectField("Animator (optional):", character.customAnimator, typeof(Animator), true);
            }

            character.headLayer  = EditorGUILayout.IntField("Head layer #:", character.headLayer);
            character.mouthLayer = EditorGUILayout.IntField("Mouth layer #:", character.mouthLayer);

            character.ikHeadTurning = EditorGUILayout.Toggle("IK head-turning?", character.ikHeadTurning);
            if (character.ikHeadTurning)
            {
                                #if UNITY_5 || UNITY_PRO_LICENSE
                EditorGUILayout.HelpBox("'IK Pass' must be enabled for this character's Base layer.", MessageType.Info);
                                #else
                EditorGUILayout.HelpBox("This features is only available with Unity 5 or Unity Pro.", MessageType.Info);
                                #endif
            }

            if (!Application.isPlaying)
            {
                character.ResetAnimator();
            }
            Animator charAnimator = character.GetAnimator();
            if (charAnimator != null && charAnimator.applyRootMotion)
            {
                character.rootTurningFactor = EditorGUILayout.Slider("Root Motion turning:", character.rootTurningFactor, 0f, 1f);
            }
            character.doWallReduction = EditorGUILayout.BeginToggleGroup("Slow movement near wall colliders?", character.doWallReduction);
            character.wallLayer       = EditorGUILayout.TextField("Wall collider layer:", character.wallLayer);
            character.wallDistance    = EditorGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f);
            EditorGUILayout.EndToggleGroup();

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms:", EditorStyles.boldLabel);

            character.neckBone      = (Transform)EditorGUILayout.ObjectField("Neck bone:", character.neckBone, typeof(Transform), true);
            character.leftHandBone  = (Transform)EditorGUILayout.ObjectField("Left hand:", character.leftHandBone, typeof(Transform), true);
            character.rightHandBone = (Transform)EditorGUILayout.ObjectField("Right hand:", character.rightHandBone, typeof(Transform), true);
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }
Ejemplo n.º 5
0
        override public void ShowGUI(List <ActionParameter> parameters)
        {
            isPlayer = EditorGUILayout.Toggle("Is player?", isPlayer);
            if (!isPlayer)
            {
                parameterID = ChooseParameterGUI("Object:", parameters, parameterID, ParameterType.GameObject);
                if (parameterID >= 0)
                {
                    constantID  = 0;
                    shapeObject = null;
                }
                else
                {
                    shapeObject = (Shapeable)EditorGUILayout.ObjectField("Object:", shapeObject, typeof(Shapeable), true);

                    constantID  = FieldToID <Shapeable> (shapeObject, constantID);
                    shapeObject = IDToField <Shapeable> (shapeObject, constantID, false);
                }
            }
            else
            {
                Player _player = null;

                if (Application.isPlaying)
                {
                    _player = KickStarter.player;
                }
                else
                {
                    _player = AdvGame.GetReferences().settingsManager.GetDefaultPlayer();
                }

                if (_player != null && _player.GetShapeable())
                {
                    shapeObject = _player.GetShapeable();
                }
                else
                {
                    shapeObject = null;
                    EditorGUILayout.HelpBox("Cannot find player with Shapeable script attached", MessageType.Warning);
                }
            }

            if (shapeObject != null && shapeObject.shapeGroups != null)
            {
                shapeGroupID   = ActionBlendShape.ShapeableGroupGUI("Shape group:", shapeObject.shapeGroups, shapeGroupID);
                disableAllKeys = EditorGUILayout.Toggle("Disable all keys?", disableAllKeys);
                if (!disableAllKeys)
                {
                    ShapeGroup _shapeGroup = shapeObject.GetGroup(shapeGroupID);
                    if (_shapeGroup != null)
                    {
                        if (_shapeGroup.shapeKeys != null && _shapeGroup.shapeKeys.Count > 0)
                        {
                            shapeKeyID = ShapeableKeyGUI(_shapeGroup.shapeKeys, shapeKeyID);
                        }
                        else
                        {
                            EditorGUILayout.HelpBox("No shape keys found.", MessageType.Info);
                        }
                    }
                    shapeValue = EditorGUILayout.Slider("New value:", shapeValue, 0f, 100f);
                }
            }
            else
            {
                EditorGUILayout.HelpBox("An object must be assigned before more options can show.", MessageType.Info);
            }

            fadeTime = EditorGUILayout.FloatField("Transition time:", fadeTime);
            if (fadeTime > 0f)
            {
                moveMethod = (MoveMethod)EditorGUILayout.EnumPopup("Move method:", moveMethod);
                if (moveMethod == MoveMethod.CustomCurve)
                {
                    timeCurve = EditorGUILayout.CurveField("Time curve:", timeCurve);
                }
                willWait = EditorGUILayout.Toggle("Wait until finish?", willWait);
            }

            AfterRunningOption();
        }
Ejemplo n.º 6
0
        public override void CharSettingsGUI()
        {
                        #if UNITY_EDITOR
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim parameters:", EditorStyles.boldLabel);

            character.moveSpeedParameter = CustomGUILayout.TextField("Move speed float:", character.moveSpeedParameter, "", "The name of the Animator float parameter set to the movement speed");
            character.turnParameter      = CustomGUILayout.TextField("Turn float:", character.turnParameter, "", "The name of the Animator float parameter set to the turning direction");
            character.talkParameter      = CustomGUILayout.TextField("Talk bool:", character.talkParameter, "", "The name of the Animator bool parameter set to True while talking");

            if (AdvGame.GetReferences() && AdvGame.GetReferences().speechManager&&
                AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.Off && AdvGame.GetReferences().speechManager.lipSyncMode != LipSyncMode.FaceFX)
            {
                if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.PortraitAndGameObject)
                {
                    character.phonemeParameter = CustomGUILayout.TextField("Phoneme integer:", character.phonemeParameter, "", "The name of the Animator integer parameter set to the lip-syncing phoneme integer");
                    if (character.GetShapeable())
                    {
                        character.lipSyncGroupID = ActionBlendShape.ShapeableGroupGUI("Phoneme shape group:", character.GetShapeable().shapeGroups, character.lipSyncGroupID);
                    }
                }
                else if (AdvGame.GetReferences().speechManager.lipSyncOutput == LipSyncOutput.GameObjectTexture)
                {
                    if (character.GetComponent <LipSyncTexture>() == null)
                    {
                        EditorGUILayout.HelpBox("Attach a LipSyncTexture script to allow texture lip-syncing.", MessageType.Info);
                    }
                }
            }

            if (!character.ikHeadTurning)
            {
                character.headYawParameter   = CustomGUILayout.TextField("Head yaw float:", character.headYawParameter, "", "The name of the Animator float parameter set to the head yaw");
                character.headPitchParameter = CustomGUILayout.TextField("Head pitch float:", character.headPitchParameter, "", "The name of the Animator float parameter set to the head pitch");
            }

            character.verticalMovementParameter = CustomGUILayout.TextField("Vertical movement float:", character.verticalMovementParameter, "", "The name of the Animator float parameter set to the vertical movement speed");
            character.isGroundedParameter       = CustomGUILayout.TextField("'Is grounded' bool:", character.isGroundedParameter, "", "The name of the Animator boolean parameter set to the 'Is Grounded' check");
            if (character is Player)
            {
                Player player = (Player)character;
                player.jumpParameter = CustomGUILayout.TextField("Jump bool:", player.jumpParameter, "", "The name of the Animator boolean parameter to set to 'True' when jumping");
            }
            character.talkingAnimation = TalkingAnimation.Standard;

            if (character.useExpressions)
            {
                character.expressionParameter = CustomGUILayout.TextField("Expression ID integer:", character.expressionParameter, "", "The name of the Animator integer parameter set to the active Expression ID number");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Mecanim settings:", EditorStyles.boldLabel);

            if (SceneSettings.IsTopDown())
            {
                character.spriteChild = (Transform)CustomGUILayout.ObjectField <Transform> ("Animator child:", character.spriteChild, true, "", "The Animator, which should be on a child GameObject");
            }
            else
            {
                character.spriteChild    = null;
                character.customAnimator = (Animator)CustomGUILayout.ObjectField <Transform> ("Animator (optional):", character.customAnimator, true, "", "The Animator, if not on the root GameObject");
            }

            character.headLayer  = CustomGUILayout.IntField("Head layer #:", character.headLayer, "", "The Animator layer used to play head animations while talking");
            character.mouthLayer = CustomGUILayout.IntField("Mouth layer #:", character.mouthLayer, "", "The Animator layer used to play mouth animations while talking");

            character.ikHeadTurning = CustomGUILayout.Toggle("IK head-turning?", character.ikHeadTurning, "", "If True, then inverse-kinematics will be used to turn the character's head dynamically, rather than playing pre-made animations");
            if (character.ikHeadTurning)
            {
                                #if UNITY_5 || UNITY_2017_1_OR_NEWER || UNITY_PRO_LICENSE
                EditorGUILayout.HelpBox("'IK Pass' must be enabled for this character's Base layer.", MessageType.Info);
                                #else
                EditorGUILayout.HelpBox("This features is only available with Unity 5 or Unity Pro.", MessageType.Info);
                                #endif
            }

            if (!Application.isPlaying)
            {
                character.ResetAnimator();
            }
            Animator charAnimator = character.GetAnimator();
            if (charAnimator != null && charAnimator.applyRootMotion)
            {
                character.rootTurningFactor = CustomGUILayout.Slider("Root Motion turning:", character.rootTurningFactor, 0f, 1f, "", "The factor by which the job of turning is left to Mecanim root motion");
            }
            character.doWallReduction = CustomGUILayout.Toggle("Slow movement near walls?", character.doWallReduction, "", "If True, then characters will slow down when walking into walls");
            if (character.doWallReduction)
            {
                character.wallLayer    = CustomGUILayout.TextField("Wall collider layer:", character.wallLayer, "", "The layer that walls are expected to be placed on");
                character.wallDistance = CustomGUILayout.Slider("Collider distance:", character.wallDistance, 0f, 2f, "", "The distance to keep away from walls");
                character.wallReductionOnlyParameter = CustomGUILayout.Toggle("Only affects Mecanim parameter?", character.wallReductionOnlyParameter, "", "If True, then the wall reduction factor will only affect the Animator move speed float parameter, and not character's actual speed");
            }

            EditorGUILayout.EndVertical();
            EditorGUILayout.BeginVertical("Button");
            EditorGUILayout.LabelField("Bone transforms:", EditorStyles.boldLabel);

            character.neckBone      = (Transform)CustomGUILayout.ObjectField <Transform> ("Neck bone:", character.neckBone, true, "", "The 'Neck bone' Transform");
            character.leftHandBone  = (Transform)CustomGUILayout.ObjectField <Transform> ("Left hand:", character.leftHandBone, true, "", "The 'Left hand bone' transform");
            character.rightHandBone = (Transform)CustomGUILayout.ObjectField <Transform> ("Right hand:", character.rightHandBone, true, "", "The 'Right hand bone' transform");
            EditorGUILayout.EndVertical();

            if (GUI.changed)
            {
                EditorUtility.SetDirty(character);
            }
                        #endif
        }