/// <summary> /// Update the mount point with the new anchor information /// </summary> /// <param name="rMountPoint">Mount point to update</param> private void UpdateMountPointBone(ref MountPoint rMountPoint) { rMountPoint.AnchorTo(rMountPoint.BoneName); // Flag the list as needing updating mIsDirty = true; }
/// <summary> /// Renders the properties of the motion so they can be changed here /// </summary> /// <param name="rLayerIndex">Layer the motion belongs to</param> /// <param name="rMotionIndex">Motions whose properites are to be listed</param> private bool DrawPointDetailItem(MountPoint rPoint) { bool lIsDirty = false; if (rPoint._Anchor == null && rPoint._BoneName.Length > 0) { rPoint.AnchorTo(rPoint._BoneName); } EditorHelper.DrawSmallTitle(rPoint.Name); EditorGUILayout.BeginHorizontal(); // Friendly name string lNewName = EditorGUILayout.TextField(new GUIContent("Name", "Friendly name of the mount point."), rPoint.Name); if (lNewName != rPoint.Name) { lIsDirty = true; rPoint.Name = lNewName; } GUILayout.Space(5); // Locked EditorGUILayout.LabelField(new GUIContent("Locked", "Determines if the MP can be moved."), GUILayout.Width(43)); bool lNewIsLocked = EditorGUILayout.Toggle(rPoint.IsLocked, GUILayout.Width(16)); if (lNewIsLocked != rPoint.IsLocked) { lIsDirty = true; rPoint.IsLocked = lNewIsLocked; } EditorGUILayout.EndHorizontal(); GUILayout.Space(5); // Bone string lBoneName = rPoint.BoneName; int lOriginalSelectedBoneIndex = GetBoneIndex(lBoneName); int lSelectedBoneIndex = EditorGUILayout.Popup("Bone", lOriginalSelectedBoneIndex, mBoneNames.ToArray()); if (lSelectedBoneIndex != lOriginalSelectedBoneIndex && lSelectedBoneIndex == (mBoneNames.Count - 1)) { lBoneName = ""; } string lNewBoneName = lBoneName; if (lSelectedBoneIndex == (mBoneNames.Count - 1)) { lNewBoneName = EditorGUILayout.TextField(new GUIContent("Bone Name", "Full path and name to the bone the MP should anchor to."), lBoneName); } else { lNewBoneName = mBoneNames[lSelectedBoneIndex]; } bool lIsBoneDirty = false; if (lNewBoneName != lBoneName) { lIsDirty = true; lIsBoneDirty = true; rPoint.BoneName = lNewBoneName; } GUILayout.Space(5); // Position Vector3 lPositionValues = rPoint.Anchor.transform.localPosition; lPositionValues.x = Convert.ToSingle(lPositionValues.x.ToString("0.0000")); lPositionValues.y = Convert.ToSingle(lPositionValues.y.ToString("0.0000")); lPositionValues.z = Convert.ToSingle(lPositionValues.z.ToString("0.0000")); Vector3 lNewPositionValues = EditorGUILayout.Vector3Field(new GUIContent("Position", "Position relative to the transform the MP belongs to."), lPositionValues); if (lNewPositionValues != lPositionValues) { lIsDirty = true; rPoint.Anchor.transform.localPosition = lNewPositionValues; } // Rotation Vector3 lRotationValues = rPoint.Anchor.transform.localRotation.eulerAngles; lRotationValues.x = Convert.ToSingle(lRotationValues.x.ToString("0.0000")); lRotationValues.y = Convert.ToSingle(lRotationValues.y.ToString("0.0000")); lRotationValues.z = Convert.ToSingle(lRotationValues.z.ToString("0.0000")); Vector3 lNewRotationValues = EditorGUILayout.Vector3Field(new GUIContent("Orientation (p, y, r)", "Rotation relative to the transform the MP belongs to."), lRotationValues); if (lNewRotationValues != lRotationValues) { lIsDirty = true; rPoint.Anchor.transform.localRotation = Quaternion.Euler(lNewRotationValues); } GUILayout.Space(5); // Allow children bool lNewAllowChildren = EditorGUILayout.Toggle(new GUIContent("Allow Children", "Determines if this mount point can have children mounted to it."), rPoint.AllowChildren); if (lNewAllowChildren != rPoint.AllowChildren) { lIsDirty = true; rPoint.AllowChildren = lNewAllowChildren; } // Set child orientation bool lNewForceOrientation = EditorGUILayout.Toggle(new GUIContent("Set Child Orientation", "Determines if this MP will force the child to rotate to match its orientation."), rPoint.ForceChildOrientation); if (lNewForceOrientation != rPoint.ForceChildOrientation) { lIsDirty = true; rPoint.ForceChildOrientation = lNewForceOrientation; } if (rPoint.ForceChildOrientation) { bool lNewInvertOrientation = EditorGUILayout.Toggle(new GUIContent("Invert Orientation", "Instead of aligning the orientations, ensure the z-axis face each other."), rPoint.InvertOrientation); if (lNewInvertOrientation != rPoint.InvertOrientation) { lIsDirty = true; rPoint.InvertOrientation = lNewInvertOrientation; } } // Ignore parent scale bool lNewIgnoreParentScale = EditorGUILayout.Toggle(new GUIContent("Preserve Child Scale", "Determines if this MP will prevent children from scaling when they connect."), rPoint.IgnoreParentScale); if (lNewIgnoreParentScale != rPoint.IgnoreParentScale) { lIsDirty = true; rPoint.IgnoreParentScale = lNewIgnoreParentScale; } // Render the parent mount point if (rPoint.ParentMountPoint != null) { EditorHelper.DrawLine(); MountPoint lParentPoint = rPoint.ParentMountPoint; EditorGUILayout.BeginHorizontal(); GUILayout.Label("Parent:", GUILayout.Width(45)); GUILayout.Label(lParentPoint.Owner.name + "." + lParentPoint.Name, GUILayout.MinWidth(100)); if (GUILayout.Button(new GUIContent("", "Select parent"), EditorHelper.BlueSelectButton, GUILayout.Width(16), GUILayout.Height(16))) { Selection.activeGameObject = lParentPoint.Owner; } if (GUILayout.Button(new GUIContent("", "Break connection"), EditorHelper.RedXButton, GUILayout.Width(16), GUILayout.Height(16))) { DisconnectMountPoints(rPoint, lParentPoint); } GUILayout.Space(2); EditorGUILayout.EndHorizontal(); } // Render the children mount points if (rPoint.ChildMountPoints.Count > 0) { EditorHelper.DrawLine(); // Show the remaining child points for (int i = 0; i < rPoint.ChildMountPoints.Count; i++) { MountPoint lChildPoint = rPoint.ChildMountPoints[i].MountPoint; if (lChildPoint.Owner == null) { continue; } EditorGUILayout.BeginHorizontal(); GUILayout.Label("Child:", GUILayout.Width(40)); GUILayout.Label(lChildPoint.Owner.name + "." + lChildPoint.Name, GUILayout.MinWidth(100)); if (GUILayout.Button(new GUIContent("", "Select child"), EditorHelper.BlueSelectButton, GUILayout.Width(16), GUILayout.Height(16))) { Selection.activeGameObject = lChildPoint.Owner; } if (GUILayout.Button(new GUIContent("", "Break connection"), EditorHelper.RedXButton, GUILayout.Width(16), GUILayout.Height(16))) { DisconnectMountPoints(lChildPoint, rPoint); } GUILayout.Space(2); EditorGUILayout.EndHorizontal(); } } GUILayout.Space(5); if (lIsBoneDirty) { UpdateMountPointBone(ref rPoint); } if (lIsDirty) { LoadOtherMountPoints(); } return(lIsDirty); }