public static void Enable(Group group) { _statesList = new ReorderableList(group.Items as IList, typeof(UnityEditor.Animations.AnimatorState)) { displayAdd = false, displayRemove = false, draggable = true, headerHeight = 0, footerHeight = 0, showDefaultBackground = false, drawElementBackgroundCallback = EditorState.DrawBackground, elementHeightCallback = index => EditorState.GetHeight(EditorState.Get(group[index])), drawElementCallback = (rect, index, isActive, isFocused) => EditorState.Draw(rect, group[index]), onReorderCallback = list => EditorState.Reorder(group) }; }
private static void DrawProperties(Rect rect, EditorState editor) { if (editor._foldout.faded < 0.01f) { return; } EditorGUI.BeginDisabledGroup(editor._foldout.faded < 0.2f || !editor._state.Enabled); const float timeFieldWidth = 54; var nameFieldWidth = rect.width - timeFieldWidth * 2 - EditorConfig.Sizes.Offset * 4; var fieldStyle = EditorConfig.Styles.GreyMiniLabel; EditorLayout.PushColor(); GUI.color *= Mathf.Clamp01(editor._foldout.faded - 0.5f) / 0.5f; EditorLayout.SetPosition(rect.x, rect.y + EditorConfig.Sizes.SingleLine); EditorLayout.Control(nameFieldWidth, r => EditorGUI.LabelField(r, ContentLabel, fieldStyle)); EditorLayout.SetWidth(timeFieldWidth); EditorLayout.Control(r => EditorGUI.LabelField(r, DelayLabel, fieldStyle)); EditorLayout.Control(r => EditorGUI.LabelField(r, DurationLabel, fieldStyle)); EditorLayout.Space(2); EditorLayout.SetWidth(nameFieldWidth); EditorGUI.BeginDisabledGroup(editor._state.IsDefaultState); editor._state.Name = EditorLayout.PropertyField(editor._state.Name, InspectorStates.Record); EditorGUI.EndDisabledGroup(); EditorLayout.SetWidth(timeFieldWidth); EditorLayout.PropertyField(ref editor._state.Delay, EditorGUI.FloatField, InspectorStates.Record); EditorLayout.PropertyField(ref editor._state.Duration, EditorGUI.FloatField, InspectorStates.Record); EditorLayout.Space(6); EditorLayout.SetWidth(rect.width - EditorConfig.Sizes.Offset * 2); EditorLayout.Control(r => editor._tweensList.DoList(r)); EditorLayout.PullColor(); EditorGUI.EndDisabledGroup(); }
private static void DrawHeader(Rect rect, EditorState editor) { var rectBackground = new Rect(rect.x, rect.y, rect.width, rect.height - 6); EditorGUI.DrawRect(rectBackground, EditorConfig.Colors.LightGrey); var rectFoldOutBack = new Rect(rect.x, rect.y, rect.width, EditorConfig.Sizes.LineHeight); GUI.Box(rectFoldOutBack, GUIContent.none, GUI.skin.box); var rectStateTabColor = new Rect(rect.x, rect.y, 2, EditorConfig.Sizes.LineHeight); var tabColor = Color.gray; if (editor._state.IsOpenedState) { tabColor = EditorConfig.Colors.Green; } if (editor._state.IsClosedState) { tabColor = EditorConfig.Colors.Red; } EditorGUI.DrawRect(rectStateTabColor, tabColor); var rectToggle = new Rect(rect.x + 5, rect.y + 2, 20, EditorConfig.Sizes.SingleLine); if (editor._state.IsDefaultState) { EditorGUI.BeginDisabledGroup(true); EditorGUI.Toggle(rectToggle, GUIContent.none, true); EditorGUI.EndDisabledGroup(); } else { editor._state.Enabled = EditorLayout.PropertyField(rectToggle, editor._state.Enabled, EditorGUI.Toggle, InspectorStates.Record); } var rectFoldout = new Rect(rect.x + 34, rect.y + 2, rect.width - 116, EditorConfig.Sizes.SingleLine); editor._foldout.target = EditorGUI.Foldout(rectFoldout, editor._foldout.target, new GUIContent(editor._state.Name), true, EditorConfig.Styles.Foldout); var rectButton = new Rect(rect.width, rect.y + 3, 24, EditorConfig.Sizes.SingleLine); EditorGUI.BeginDisabledGroup(editor._state.IsDefaultState); if (GUI.Button(rectButton, EditorConfig.Content.IconToolbarMinus, EditorConfig.Styles.PreButton)) { editor.OnRemoveButton(); } EditorGUI.EndDisabledGroup(); rectButton.x -= 24; if (GUI.Button(rectButton, EditorConfig.Content.IconReturn, EditorConfig.Styles.IconButton)) { editor._state.Apply(); } rectButton.x -= 24; if (GUI.Button(rectButton, EditorConfig.Content.IconRecord, EditorConfig.Styles.IconButton)) { EditorActions.Add(editor._state.Capture, InspectorStates.States, "Record state values"); } }
public static void Draw(Rect rect, EditorState editor) { rect.width += 5; DrawHeader(rect, editor); DrawProperties(rect, editor); }
private void PrecessUndo() { EditorGroup.Enable(States.Group); EditorState.Reorder(States.Group); Repaint(); }