public void OnGUI()
        {
            if (state.selection.canChangeAnimationClip)
            {
                var newClip = DoClipPopup(state.activeAnimationClip, AnimationWindowStyles.animClipToolbarPopup);
                if (state.selection.canCreateClips)
                {
                    addCI.SetSourceView();
                    if (GUILayout.Button(new GUIContent("+", "Create New Clip..."), EditorStyles.toolbarButton))
                    {
                        newClip = AnimationWindowUtility.CreateNewClip(state.selection.rootGameObject.name);
                        if (newClip)
                        {
                            AnimationWindowUtility.AddClipToAnimationPlayerComponent(state.activeAnimationPlayer, newClip);
                            addCI.selectedClip = newClip;
                            addCI.SendEvent();
                        }
                    }
                }
                if (state.activeAnimationClip != newClip)
                {
                    state.activeAnimationClip = newClip;

                    //  Layout has changed, bail out now.
                    EditorGUIUtility.ExitGUI();
                }
            }
            else if (state.activeAnimationClip != null)
            {
                Rect r = EditorGUILayout.GetControlRect(false, EditorGUIUtility.singleLineHeight, AnimationWindowStyles.toolbarLabel);
                EditorGUI.LabelField(r, CurveUtility.GetClipName(state.activeAnimationClip), AnimationWindowStyles.toolbarLabel);
            }
        }
        private void DisplayClipMenu(Rect position, int controlID, AnimationClip clip)
        {
            AnimationClip[] clips       = GetOrderedClipList();
            GUIContent[]    menuContent = GetClipMenuContent(clips);
            int             selected    = ClipToIndex(clips, clip);

            // Center popup menu around button widget
            if (Application.platform == RuntimePlatform.OSXEditor)
            {
                position.y = position.y - selected * EditorGUI.kSingleLineHeight - kMenuOffsetMac;
            }

            ClipPopupCallbackInfo.instance = new ClipPopupCallbackInfo(controlID);

            EditorUtility.DisplayCustomMenu(position, menuContent, null, selected, (userData, options, index) =>
            {
                if (index < clips.Length)
                {
                    ClipPopupCallbackInfo.SetSelectedClip(clips[index]);
                }
                else
                {
                    AnimationClip newClip = AnimationWindowUtility.CreateNewClip(state.selection.rootGameObject.name);
                    if (newClip)
                    {
                        AnimationWindowUtility.AddClipToAnimationPlayerComponent(state.activeAnimationPlayer, newClip);
                        ClipPopupCallbackInfo.SetSelectedClip(newClip);
                    }
                }

                ClipPopupCallbackInfo.SendEvent();
            }, null);
        }
        private void DisplayClipMenu(Rect position, AnimationClip clip)
        {
            popupCI.SetSourceView();

            AnimationSelectorWindow.DrawPresetButton(clip, GetOrderedClipList(), position, (selectedClip) => {
                popupCI.selectedClip = selectedClip;
                popupCI.SendEvent();
            });
        }