void DrawRemoveAnimationClipButton(int index) { const float deleteButtonWidth = 20; Color defaultColor = GUI.color; GUI.color = Color.gray; if (GUILayout.Button("-", GUILayout.Width(deleteButtonWidth))) { Undo.RecordObject(EditorWindowInfo.Selector.AnimationEvents, "Remove AnimationClipEvent"); EditorWindowInfo.Selector.AnimationEvents.RemoveAt(index); EditorWindowInfo.Selector.AnimationClipEvents = null; EditorWindowInfo.StopAnimation(); } GUI.color = defaultColor; }
void DrawAnimationClipControlButton(int index, AnimationClipEvents animationClipEvents) { string buttonName = "Don't have AnimationClip"; Color defaultColor = GUI.color; if (animationClipEvents.AnimationClip == null) { GUI.color = Color.red; } else if (EditorWindowInfo.Selector.AnimationClipEvents == animationClipEvents) { buttonName = animationClipEvents.AnimationClip.name; GUI.color = Color.green; } else { buttonName = animationClipEvents.AnimationClip.name; GUI.color = defaultColor; } if (GUILayout.Button(buttonName)) { if (EditorWindowInfo.IsPlaying) { if (animationClipEvents.AnimationClip != null) { EditorWindowInfo.StopAnimation(); } } else { EditorWindowInfo.StopAnimation(); } EditorWindowInfo.Selector.AnimationClipEvents = animationClipEvents; } GUI.color = defaultColor; }