コード例 #1
0
        protected override void DrawCreateButtonGUI()
        {
            GatoGUILayout.Button(
                LocalizeText.instance.langPair.createAnimFileButtonText,
                () => {
                var animController = originalAvatar.StandingAnimController;

                var createdAnimClip = FaceEmotion.CreateBlendShapeAnimationClip(animName, originalAvatar.AnimSavedFolderPath, editAvatar);
                if (selectedHandAnim != HandPose.HandPoseType.NoSelection)
                {
                    HandPose.AddHandPoseAnimationKeysFromOriginClip(createdAnimClip, handPoseAnim);
                    animController[AnimationsGUI.HANDANIMS[(int)selectedHandAnim - 1]] = createdAnimClip;
                    EditorUtility.SetDirty(animController);

                    FaceEmotion.ResetToDefaultFaceEmotion(editAvatar);
                }

                originalAvatar.StandingAnimController = animController;
                editAvatar.StandingAnimController     = animController;

                animationsGUI.ResetPathMissing(AnimationsGUI.HANDANIMS[(int)selectedHandAnim - 1]);
            },
                selectedHandAnim != HandPose.HandPoseType.NoSelection &&
                handPoseAnim != null);
        }
コード例 #2
0
        protected override void DrawCreateButtonGUI()
        {
            GatoGUILayout.Button(
                LocalizeText.instance.langPair.createAnimFileButtonText,
                () =>
            {
                var controller      = originalAvatar.FxController;
                var createdAnimClip = FaceEmotion.CreateBlendShapeAnimationClip(
                    animName,
                    originalAvatar.AnimSavedFolderPath,
                    editAvatar,
                    true);

                // Stateがない場合は作成のみ
                if (states.Any())
                {
                    states[selectedStateIndex].state.motion = createdAnimClip;
                    EditorUtility.SetDirty(controller);

                    // 可能であればもう一方の手も同じAnimationClipを設定する
                    if (setLeftAndRight)
                    {
                        var layerName          = editAvatar.FxController.layers[editAvatar.TargetFxLayerIndex].name;
                        string targetLayerName = string.Empty;
                        if (layerName == "Left Hand")
                        {
                            targetLayerName = "Right Hand";
                        }
                        else if (layerName == "Right Hand")
                        {
                            targetLayerName = "Left Hand";
                        }

                        if (!string.IsNullOrEmpty(targetLayerName))
                        {
                            var targetLayer = editAvatar.FxController.layers
                                              .Where(l => l.name == targetLayerName)
                                              .SingleOrDefault();

                            if (targetLayer != null)
                            {
                                var targetStateName = states[selectedStateIndex].state.name;
                                var targetState     = targetLayer.stateMachine.states
                                                      .Where(s => s.state.name == targetStateName)
                                                      .SingleOrDefault();

                                if (targetState.state != null)
                                {
                                    targetState.state.motion = createdAnimClip;
                                    EditorUtility.SetDirty(controller);
                                }
                            }
                        }
                    }
                }

                FaceEmotion.ResetToDefaultFaceEmotion(editAvatar);
                originalAvatar.FxController = controller;
                editAvatar.FxController     = controller;
            },
                originalAvatar.FxController != null);
        }