public void ChangeSaveAnimationState( string animName = "", HandPose.HandPoseType selectedHandAnim = HandPose.HandPoseType.NoSelection, AnimationClip handPoseAnim = null) { this.animName = animName; this.selectedHandAnim = selectedHandAnim; if (handPoseAnim is null) { handPoseAnim = HandPose.GetHandAnimationClip(this.selectedHandAnim); } this.handPoseAnim = handPoseAnim; }
/// <summary> /// 指定したBlendShapeのアニメーションファイルを作成する /// </summary> public static AnimationClip CreateBlendShapeAnimationClip(string fileName, string saveFolderPath, List <SkinnedMesh> skinnedMeshList, HandPose.HandPoseType selectedHandAnim, List <string> exclusions) { AnimationClip animClip = new AnimationClip(); if (fileName == "") { fileName = "face_emotion"; } foreach (var skinnedMesh in skinnedMeshList) { if (!skinnedMesh.isOpenBlendShapes) { continue; } string path = GetHierarchyPath(skinnedMesh.renderer.gameObject); for (int i = 0; i < skinnedMesh.blendShapeNum; i++) { var blendshape = skinnedMesh.blendshapes[i]; if (!blendshape.isExclusion && blendshape.isContains) { float keyValue = skinnedMesh.renderer.GetBlendShapeWeight(blendshape.id); Keyframe startKeyframe = new Keyframe(0, keyValue); Keyframe endKeyframe = new Keyframe(1 / 60.0f, keyValue); AnimationCurve curve = new AnimationCurve(); curve.AddKey(startKeyframe); curve.AddKey(endKeyframe); animClip.SetCurve(path, typeof(SkinnedMeshRenderer), "blendShape." + blendshape.name, curve); } } } // 特定の手の形を追加する if (selectedHandAnim != HandPose.HandPoseType.None) { HandPose.AddHandPoseAnimationKeys(animClip, selectedHandAnim); } AssetDatabase.CreateAsset(animClip, AssetDatabase.GenerateUniqueAssetPath(saveFolderPath + fileName + ".anim")); AssetDatabase.SaveAssets(); AssetDatabase.Refresh(); return(animClip); }
/// <summary> /// 表情用のAnimationClipを作成する /// </summary> public static void CreateAndSetAnimClip(string animFileName, string saveFolderPath, List <SkinnedMesh> skinnedMeshList, ref AnimatorOverrideController controller, HandPose.HandPoseType selectedHandAnim, List <string> exclusions) { var animClip = CreateBlendShapeAnimationClip(animFileName, saveFolderPath, skinnedMeshList, selectedHandAnim, exclusions); if (selectedHandAnim != HandPose.HandPoseType.None) { controller[HANDANIMS[(int)selectedHandAnim - 1]] = animClip; } }