public void RemoveAll() { for (int i = 0; i < m_constraints.Count; ++i) { var c = m_constraints[i]; c.DoRemove(); MUndo.DestroyObj(c); } m_constraints.Clear(); }
public void RemoveAt(int idx) { Dbg.Assert(idx < m_constraints.Count, "ConstraintController.RemoveAt: idx beyond range: {0}, Count : {1}"); var c = m_constraints[idx]; c.DoRemove(); m_constraints.RemoveAt(idx); MUndo.DestroyObj(c); //destroy constraint }
private void _DelConstraintForLeg(Bones eFoot, Bones eLowerLeg, Bones eUpperLeg) { Transform root = _bones[(int)Bones.Root]; Transform foot = _bones[(int)eFoot]; Transform lleg = _bones[(int)eLowerLeg]; Transform uleg = _bones[(int)eUpperLeg]; string targetName = eFoot == Bones.FootL ? "LFTarget" : "RFTarget"; Transform target = root.Find(targetName); if (target != null) { var cstack = foot.GetComponent <ConstraintStack>(); if (cstack != null) { cstack.RemoveAll(); MUndo.DestroyObj(cstack); } MUndo.DestroyObj(target.gameObject); _execLog.AppendFormat("removed IKTarget of {0}\n", targetName); } if (foot != null) { var cstack = foot.GetComponent <ConstraintStack>(); if (cstack != null) { cstack.RemoveAll(); MUndo.DestroyObj(cstack); _execLog.AppendFormat("removed constraints on {0}\n", foot.name); } } if (lleg != null) { var cp = lleg.GetComponent <AngleConstraintMB>(); if (cp != null) { MUndo.DestroyObj(cp); _execLog.AppendFormat("removed constraint on {0}\n", lleg.name); } } if (uleg != null) { var cp = uleg.GetComponent <ConeConstraintMB>(); if (cp != null) { MUndo.DestroyObj(cp); _execLog.AppendFormat("removed constraint on {0}\n", uleg.name); } } }
private void _DelConstraintForArm(Bones eHand, Bones eLowerArm, Bones eUpperArm) { Transform pelvis = _bones[(int)Bones.Pelvis]; Transform hand = _bones[(int)eHand]; Transform larm = _bones[(int)eLowerArm]; Transform uarm = _bones[(int)eUpperArm]; string targetName = eHand == Bones.HandL ? "LHTarget" : "RHTarget"; Transform target = pelvis.Find(targetName); if (target != null) { MUndo.DestroyObj(target.gameObject); _execLog.AppendFormat("removed IKTarget of {0}\n", targetName); } if (hand != null) { var cp = hand.GetComponent <CCDSolverMB>(); if (cp != null) { MUndo.DestroyObj(cp); var cstack = hand.GetComponent <ConstraintStack>(); MUndo.DestroyObj(cstack); _execLog.AppendFormat("removed IKSolver on {0}\n", hand.name); } } if (larm != null) { var cp = larm.GetComponent <AngleConstraintMB>(); if (cp != null) { MUndo.DestroyObj(cp); _execLog.AppendFormat("removed constraint on {0}\n", larm.name); } } if (uarm != null) { var cp = uarm.GetComponent <ConeConstraintMB>(); if (cp != null) { MUndo.DestroyObj(cp); _execLog.AppendFormat("removed constraint on {0}\n", uarm.name); } } }
private void _ExecuteDelConstraints() { _execLog.Remove(0, _execLog.Length); _DelConstraintForArm(Bones.HandL, Bones.LowerArmL, Bones.UpperArmL); _DelConstraintForArm(Bones.HandR, Bones.LowerArmR, Bones.UpperArmR); _DelConstraintForLeg(Bones.FootL, Bones.LowerLegL, Bones.UpperLegL); _DelConstraintForLeg(Bones.FootR, Bones.LowerLegR, Bones.UpperLegR); Transform pelvis = _bones[(int)Bones.Pelvis]; if (pelvis) { var cs = pelvis.GetComponent <ConstraintStack>(); if (cs) { cs.RemoveAll(); MUndo.DestroyObj(cs); } } }
public override void OnInspectorGUI() { EmptyMarker o = (EmptyMarker)target; EditorGUI.BeginChangeCheck(); var newMf = (MeshFilter)EditorGUILayout.ObjectField("MeshFilter", o.mf, typeof(MeshFilter), true); if (EditorGUI.EndChangeCheck()) { o.mf = newMf; EUtil.SetDirty(o); } EUtil.PushGUIEnable(o.mf != null); { EditorGUI.BeginChangeCheck(); var newMesh = (Mesh)EditorGUILayout.ObjectField("Mesh", o.mesh, typeof(Mesh), false); if (EditorGUI.EndChangeCheck()) { o.mesh = newMesh; EUtil.SetDirty(o); } EditorGUI.BeginChangeCheck(); var newMat = (Material)EditorGUILayout.ObjectField("Material", o.material, typeof(Material), false); if (EditorGUI.EndChangeCheck()) { o.material = newMat; EUtil.SetDirty(o); } EditorGUI.BeginChangeCheck(); var newSelMat = (Material)EditorGUILayout.ObjectField("Selected Material", o.selectedMaterial, typeof(Material), false); if (EditorGUI.EndChangeCheck()) { o.selectedMaterial = newSelMat; EUtil.SetDirty(o); } } EUtil.PopGUIEnable(); EditorGUI.BeginChangeCheck(); o.jumpTo = (Transform)EditorGUILayout.ObjectField("Jump To", o.jumpTo, typeof(Transform), true); if (EditorGUI.EndChangeCheck()) { EUtil.SetDirty(o); } // create "mesh" child object to hold marker EditorGUILayout.BeginHorizontal(); { Rect rc = GUILayoutUtility.GetRect(new GUIContent("Presets"), GUI.skin.button); if (GUI.Button(rc, new GUIContent("Presets", "select presets marker"))) { PopupWindow.Show(rc, new EmptyMarkerPresetsPopup(o)); } if (GUILayout.Button(new GUIContent("Delete", "delete marker"))) { if (o.mf != null) { MUndo.DestroyObj(o.mf.gameObject); } MUndo.DestroyObj(o); EditorGUIUtility.ExitGUI(); } if (o.jumpTo != null) { if (GUILayout.Button(new GUIContent("Target", "jump to the target transform"))) { Selection.activeTransform = o.jumpTo; } } } EditorGUILayout.EndHorizontal(); }