protected override void DrawExtraInspector() { editor.DrawEnumPopupLayout(_space, value => space = (RotationSpace)value, "Space"); editor.DrawEnumPopupLayout(_orientation, value => orientation = (RotationOrientation)value, "Orientation"); if (_orientation != RotationOrientation.Free) { if (EditorKit.IndentedButton("Correct Orientations")) { Undo.RecordObject(this, editor.undoString); for (int i=0; i<count; i++) { var value = GetValue(i); if (_space == RotationSpace.Path) { if (_orientation == RotationOrientation.ForwardTangent) { value = Quaternion.LookRotation( path.GetTangent(path.GetLocationByLength(GetPosition(i)), Space.Self), value * Vector3.up); } else if (_orientation == RotationOrientation.BackTangent) { value = Quaternion.LookRotation( -path.GetTangent(path.GetLocationByLength(GetPosition(i)), Space.Self), value * Vector3.up); } } else { if (_orientation == RotationOrientation.ForwardTangent) { value = Quaternion.LookRotation( path.GetTangent(path.GetLocationByLength(GetPosition(i))), value * Vector3.up); } else if (_orientation == RotationOrientation.BackTangent) { value = Quaternion.LookRotation( -path.GetTangent(path.GetLocationByLength(GetPosition(i))), value * Vector3.up); } } SetValue(i, value); } EditorUtility.SetDirty(this); } } }
protected sealed override void Editor_OnInspectorGUI() { // Check Path if (!path) { EditorGUILayout.HelpBox("Require Path Component!", MessageType.Error, true); if (_currentEditing == this) { SetCurrentEditing(null); } return; } // personalized Color _rect = EditorGUILayout.GetControlRect(true, _editButtonHeight); var rect2 = new Rect(_rect.x + 3f, _rect.y + 3f, _rect.height - 6f, _rect.height - 6f); if (GUI.Button(rect2, GUIContent.none)) { Undo.RecordObject(this, "Change Color"); personalizedColor = EditorKit.randomColor; EditorUtility.SetDirty(this); } EditorKit.RecordAndSetGUIColor(EditorKit.defaultContentColor); GUI.DrawTexture(rect2, EditorGUIUtility.whiteTexture); EditorKit.RestoreGUIColor(); EditorKit.RecordAndSetGUIColor(personalizedColor); rect2.Set(rect2.x + 1f, rect2.y + 1f, rect2.width - 2f, rect2.height - 2f); GUI.DrawTexture(rect2, EditorGUIUtility.whiteTexture); EditorKit.RestoreGUIColor(); // Edit Button _rect.x += EditorGUIUtility.labelWidth; _rect.width = _editButtonWidth; EditorGUI.BeginChangeCheck(); EditorKit.RecordAndSetGUIContentColor(EditorKit.defaultContentColor); bool edit = GUI.Toggle(_rect, _currentEditing == this, EditorAssets.editTexture, EditorKit.buttonStyle); EditorKit.RestoreGUIContentColor(); if (EditorGUI.EndChangeCheck()) { SetCurrentEditing(edit ? this : null); } // Edit Label _rect.x = _rect.xMax + _horizontalInterval; _rect.width = 128f; EditorGUI.LabelField(_rect, "Edit Keys", middleLeftLabel); // DrawExtraInspector DrawExtraInspector(); // Sort Button if (!isSorted) { if (EditorKit.IndentedButton("Sort")) { Undo.RecordObject(this, editor.undoString); Sort(); EditorUtility.SetDirty(this); } } }