コード例 #1
0
 /// <summary>
 /// 展示选中的功能界面
 /// </summary>
 /// <param name="editor"></param>
 public virtual void Show(IMetaEditor editor)
 {
     EditorGUI.FocusTextInControl("");
     if (!editor.Initialize())
     {
         return;
     }
     this.current_editor            = editor;
     this.save_CurrentEditor.String = editor.GetType().FullName;
     this.editorAttribute           =
         (TabAttribute)
         ((IEnumerable <object>)editor.GetType().GetCustomAttributes(true)).FirstOrDefault <object>(
             (Func <object, bool>)(x => x is TabAttribute));
     this.editorRender = new Action(this.current_editor.OnGUI);
 }
コード例 #2
0
        private void OnGUI()
        {
            try
            {
                CoreStyles.Update();
                if (!IPanel <T> .style_IsInitialized)
                {
                    this.InitializeStyles();
                }

                EditorGUILayout.Space();
                if (this.editorRender == null || this.current_editor == null)
                {
                    this.editorRender   = (Action)null;
                    this.current_editor = (IMetaEditor)null;
                }

                this.defalutColor = GUI.backgroundColor;

                using (new GUIHelper.Horizontal(new GUILayoutOption[2]
                {
                    GUILayout.ExpandWidth(true),
                    GUILayout.ExpandHeight(true)
                }))
                {
                    using (new GUIHelper.Vertical(CoreStyles.tabArea, new GUILayoutOption[2]
                    {
                        GUILayout.Width(150f),
                        GUILayout.ExpandHeight(true)
                    }))
                    {
                        this.tabsScroll = EditorGUILayout.BeginScrollView(this.tabsScroll);
                        this.DrawTabs();
                        EditorGUILayout.EndVertical();
                        EditorGUILayout.EndScrollView();


                        Rect rect = EditorGUILayout.BeginVertical(CoreStyles.tabArea, GUILayout.ExpandWidth(true),
                                                                  GUILayout.ExpandHeight(true));
                        this.editorScroll = EditorGUILayout.BeginScrollView(this.editorScroll);
                        if (this.current_editor != null && this.editorRender != null)
                        {
                            if (this.editorAttribute != null)
                            {
                                this.DrawTitle(this.editorAttribute.Title);
                            }
                            try
                            {
                                if (EditorApplication.isCompiling)
                                {
                                    GUILayout.Label("Compiling...", CoreStyles.centeredMiniLabel,
                                                    GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                                }
                                else
                                {
                                    if (Event.current.type == EventType.Repaint)
                                    {
                                        IPanel <T> .currectEditorRect = rect;
                                    }
                                    this.editorRender();
                                }
                            }
                            catch (Exception ex)
                            {
                                Debug.LogException(ex);
                                GUILayout.Label(ex.ToString(), IPanel <T> .style_Exeption);
                            }
                        }
                        else
                        {
                            GUILayout.Label("Nothing selected", CoreStyles.centeredMiniLabel,
                                            GUILayout.ExpandHeight(true), GUILayout.ExpandWidth(true));
                        }

                        EditorGUILayout.EndScrollView();
                    }
                }
            }
            catch (ArgumentException ex)
            {
                if (ex.Message.StartsWith("Getting control") && ex.Message.StartsWith("GUILayout"))
                {
                    return;
                }
                Debug.LogException((Exception)ex);
            }
        }