private void LateUpdate() { if (Input.GetKeyDown(KeyCode.Y)) { ExportFacialAnimationClipTest(); } if (!_recording) { return; } _recordedTime += Time.deltaTime; var p = new CharacterFacialData.SerializeHumanoidFace(); for (int i = 0; i < _smeshs.Length; i++) { var mesh = new CharacterFacialData.SerializeHumanoidFace.MeshAndBlendshape(); mesh.path = _smeshs[i].name; mesh.blendShapes = new float[_smeshs[i].sharedMesh.blendShapeCount]; for (int j = 0; j < _smeshs[i].sharedMesh.blendShapeCount; j++) { var tname = _smeshs[i].sharedMesh.GetBlendShapeName(j); var useThis = true; foreach (var item in _exclusiveBlendshapeNames) { if (item.IndexOf(tname, StringComparison.Ordinal) >= 0) { useThis = false; } } if (useThis) { mesh.blendShapes[j] = _smeshs[i].GetBlendShapeWeight(j); } } p.Smeshes.Add(mesh); } if (!IsSame(p, _past)) { p.FrameCount = _frameCount; p.Time = _recordedTime; _facialData.Facials.Add(p); _past = new CharacterFacialData.SerializeHumanoidFace(p); } _frameCount++; }
//フレーム内の差分が無いかをチェックするやつ。 private bool IsSame(CharacterFacialData.SerializeHumanoidFace a, CharacterFacialData.SerializeHumanoidFace b) { if (a == null || b == null || a.Smeshes.Count == 0 || b.Smeshes.Count == 0) { return(false); } if (a.BlendShapeNum() != b.BlendShapeNum()) { return(false); } return(!a.Smeshes.Where((t1, i) => t1.blendShapes.Where((t, j) => Mathf.Abs(t - b.Smeshes[i].blendShapes[j]) > 1).Any()).Any()); }