private void Done() { SaveMorphMesh(); _morphAnimation.IsDone = true; _morphAnimation.Bones = _skinnedMeshRenderer.bones.ToList(); _morphAnimation.BindPosesPosition = new List <Vector3>(); _morphAnimation.BindPosesRotation = new List <Quaternion>(); _morphAnimation.BindPosesScale = new List <Vector3>(); for (int i = 0; i < _morphAnimation.Bones.Count; i++) { _morphAnimation.BindPosesPosition.Add(_morphAnimation.Bones[i].localPosition); _morphAnimation.BindPosesRotation.Add(_morphAnimation.Bones[i].localRotation); _morphAnimation.BindPosesScale.Add(_morphAnimation.Bones[i].localScale); } _morphAnimation.AnimationFrames = new List <MorphAnimationFrame>(); _morphAnimation.TimeLine = new List <MorphAnimationFrame>(); _morphAnimation.Triangles = null; _morphAnimation.Vertexs = null; for (int i = 0; i < _morphAnimation.Bones.Count; i++) { MorphBone mb = _morphAnimation.Bones[i].GetComponent <MorphBone>(); if (mb) { DestroyImmediate(mb); } } MorphAnimationWindow maw = EditorWindow.GetWindow <MorphAnimationWindow>(); maw.titleContent = new GUIContent(EditorGUIUtility.IconContent("Animation Icon")); maw.titleContent.text = "Morph Editor"; maw.autoRepaintOnSceneChange = true; maw.Init(_morphAnimation); maw.Show(); }
private void OnEnable() { _morphAnimation = target as MorphAnimation; _transform = _morphAnimation.transform; _boneSize = 0.1f; ReSet(); if (!_morphAnimation.IsApprove) { return; } if (_morphAnimation.IsDone) { return; } _skinnedMeshRenderer = _transform.GetComponent <SkinnedMeshRenderer>(); _mesh = _skinnedMeshRenderer.sharedMesh; _meshCollider = _transform.GetComponent <MeshCollider>(); _currentCheckedBone = null; _currentCheckedMorphBone = null; _currentCheckedVertex = null; _MAEditType = MAEditType.Bone; _MATool = MATool.Move; _vertexHandleType = HandleType.Wire; _vertexIconSize = 0.01f; _reNameBone = false; _newNameBone = ""; _showMorphSetting = true; _showRenderSetting = true; _showMaterials = false; SaveMorphMesh(); }
private void PreviewBoneChild(Transform bone, int retract) { EditorGUILayout.BeginHorizontal(); bool checkd = _currentCheckedBone == bone; SetGUIColor(Color.white, checkd ? Color.yellow : Color.white); GUILayout.Space(retract); if (GUILayout.Button(bone.name, "Minibutton", GUILayout.Width(100))) { _currentCheckedBone = bone; _currentCheckedMorphBone = bone.GetComponent <MorphBone>(); } if (retract == 0) { MorphBone mb = bone.GetComponent <MorphBone>(); bool hide = (mb != null ? mb.IsHideInRootBone : false); if (GUILayout.Button("", hide ? "OL Plus" : "OL Minus", GUILayout.Width(20))) { mb = bone.GetComponent <MorphBone>(); if (mb != null) { mb.IsHideInRootBone = !hide; } } } EditorGUILayout.EndHorizontal(); if (checkd) { SetGUIColor(Color.white, Color.yellow); EditorGUILayout.BeginVertical("HelpBox"); EditorGUILayout.BeginHorizontal(); GUILayout.Label("External Range"); _currentCheckedMorphBone.ExternalRange = EditorGUILayout.FloatField(_currentCheckedMorphBone.ExternalRange); GUILayout.Label("Internal Range"); _currentCheckedMorphBone.InternalRange = EditorGUILayout.FloatField(_currentCheckedMorphBone.InternalRange); EditorGUILayout.EndHorizontal(); EditorGUILayout.BeginHorizontal(); GUILayout.FlexibleSpace(); if (GUILayout.Button("Apply Range", "Minibutton")) { ApplyRange(); } EditorGUILayout.EndHorizontal(); EditorGUILayout.EndVertical(); } MorphBone mb1 = bone.GetComponent <MorphBone>(); if (mb1 != null && !mb1.IsHideInRootBone) { for (int i = 0; i < bone.childCount; i++) { Transform tf = bone.GetChild(i); if (tf) { PreviewBoneChild(tf, retract + 50); } } } }