protected override void Editor_OnInspectorGUI() { Color foregroundColor = EditorKit.defaultContentColor; EditorGUILayout.Space(); _selectedPageIndex = GUILayout.Toolbar(_selectedPageIndex, pageTitles, EditorStyles.miniButton); EditorGUILayout.Space(); Rect rect = EditorGUILayout.GetControlRect(false, 1f); EditorGUI.DrawRect(rect, foregroundColor * 0.5f); EditorGUILayout.Space(); editor.serializedObject.Update(); switch (_selectedPageIndex) { case 0: // Interpolator { EditorGUILayout.PropertyField(_interpolatorProp); break; } case 1: // Animation { EditorGUILayout.PropertyField(_startDelayProp); EditorGUILayout.PropertyField(_durationProp); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_wrapModeProp); EditorGUILayout.PropertyField(_playModeProp); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_updateModeProp); EditorGUI.BeginDisabledGroup(_updateMode == UpdateMode.FixedUpdate); EditorGUILayout.PropertyField(_timeModeProp); EditorGUI.EndDisabledGroup(); EditorGUILayout.Space(); rect = EditorGUILayout.GetControlRect(); EditorGUI.LabelField(rect, " ", _animations.Count.ToString()); _showAnimations = EditorGUI.Foldout(rect, _showAnimations, "Animations", true); if (_showAnimations) { EditorGUI.indentLevel++; EditorGUI.BeginDisabledGroup(true); for (int i = 0; i < _animations.Count; i++) { stringBuilder.Length = 8; EditorGUILayout.ObjectField(stringBuilder.Append(i).ToString(), _animations[i], typeof(TweenAnimation), false); } EditorGUI.EndDisabledGroup(); EditorGUI.indentLevel--; } break; } case 2: // Event { EditorGUILayout.PropertyField(_onForwardToEndingProp); EditorGUILayout.Space(); EditorGUILayout.PropertyField(_onBackToBeginningProp); break; } } editor.serializedObject.ApplyModifiedProperties(); EditorGUILayout.Space(); rect = EditorGUILayout.GetControlRect(true, 1f); EditorGUI.DrawRect(rect, foregroundColor * 0.5f); EditorGUILayout.Space(); rect = EditorGUILayout.GetControlRect(true); // 绘制预览按钮 Rect previewRect = rect; previewRect.width = 54f; rect.xMin = rect.xMax - rect.height; if (Application.isPlaying) { EditorKit.RecordAndSetGUIBackgroundColor(enabled ? _personalizedColor : GUI.backgroundColor); enabled = GUI.Toggle(previewRect, enabled, "Play", EditorStyles.miniButton); EditorKit.RestoreGUIBackgroundColor(); } else { EditorKit.RecordAndSetGUIBackgroundColor(_isPreviewInEditor ? _personalizedColor : GUI.backgroundColor); previewInEditor = GUI.Toggle(previewRect, _isPreviewInEditor, "Preview", EditorStyles.miniButton); EditorKit.RestoreGUIBackgroundColor(); } // 进度条 previewRect.x = previewRect.xMax + 8f; previewRect.xMax = rect.xMin - 8f; // 鼠标开始拖动 if (Event.current.type == EventType.MouseDown) { if (previewRect.Contains(Event.current.mousePosition)) { draggingInEditor = true; } } // 鼠标结束拖动 if (Event.current.rawType == EventType.MouseUp) { if (_isDraggingInEditor) { draggingInEditor = false; editor.Repaint(); } } // 绘制进度条 EditorGUI.BeginChangeCheck(); float time01 = EditorKit.ProgressBar(previewRect, _normalizedTime, progressBackground, _personalizedColor, foregroundColor, true); if (EditorGUI.EndChangeCheck() && _isDraggingInEditor) { normalizedTime = time01; } // 绘制个性化颜色按钮 if (GUI.Button(rect, GUIContent.none)) { Undo.RecordObject(this, "Change Color"); _personalizedColor = EditorKit.randomColor; EditorUtility.SetDirty(this); } // 绘制颜色块 EditorKit.RecordAndSetGUIColor(foregroundColor); GUI.DrawTexture(rect, EditorGUIUtility.whiteTexture); EditorKit.RestoreGUIColor(); EditorKit.RecordAndSetGUIColor(_personalizedColor); previewRect.Set(rect.x + 1f, rect.y + 1f, rect.width - 2f, rect.height - 2f); GUI.DrawTexture(previewRect, EditorGUIUtility.whiteTexture); EditorKit.RestoreGUIColor(); EditorGUILayout.Space(); }