UnityEditor.AnimationWindowClipPopup.OnGUI C# (CSharp) Method

OnGUI() public method

public OnGUI ( ) : void
return void
        public void OnGUI()
        {
            AnimationWindowSelectionItem selectedItem = this.state.selectedItem;
            if ((selectedItem != null) && selectedItem.canChangeAnimationClip)
            {
                string[] clipMenuContent = this.GetClipMenuContent();
                EditorGUI.BeginChangeCheck();
                this.selectedIndex = EditorGUILayout.Popup(this.ClipToIndex(this.state.activeAnimationClip), clipMenuContent, EditorStyles.toolbarPopup, new GUILayoutOption[0]);
                if (EditorGUI.EndChangeCheck())
                {
                    if (clipMenuContent[this.selectedIndex] == AnimationWindowStyles.createNewClip.text)
                    {
                        AnimationClip newClip = AnimationWindowUtility.CreateNewClip(selectedItem.rootGameObject.name);
                        if (newClip != null)
                        {
                            AnimationWindowUtility.AddClipToAnimationPlayerComponent(this.state.activeAnimationPlayer, newClip);
                            this.state.selection.UpdateClip(this.state.selectedItem, newClip);
                            this.state.currentTime = 0f;
                            this.state.ResampleAnimation();
                            GUIUtility.ExitGUI();
                        }
                    }
                    else
                    {
                        this.state.selection.UpdateClip(this.state.selectedItem, this.IndexToClip(this.selectedIndex));
                        this.state.currentTime = 0f;
                        this.state.ResampleAnimation();
                    }
                }
            }
        }
    }

Usage Example

Exemplo n.º 1
0
 private void ClipSelectionDropDownOnGUI()
 {
     m_ClipPopup.OnGUI();
 }