Example #1
0
            private void Eve(Event e)
            {
                if (e.button == 0 && e.clickCount == 1 &&
                    (!tableViewCalc.view.Contains(e.mousePosition) ||
                     (tableViewCalc.view.Contains(e.mousePosition) &&
                      !tableViewCalc.content.Contains(e.mousePosition))))
                {
                    tableViewCalc.SelectNone();
                    window.Repaint();
                }
                DragAndDropIInfo info = DragAndDropUtil.Drag(e, tableViewCalc.view);

                if (info.enterArera && info.compelete)
                {
                    for (int i = 0; i < info.paths.Length; i++)
                    {
                        AddCollectItem(info.paths[i]);
                    }
                }
                if (e.button == 1 && e.clickCount == 1 &&
                    tableViewCalc.content.Contains(e.mousePosition))
                {
                    GenericMenu menu = new GenericMenu();
                    menu.AddItem(new GUIContent("Delete"), false, () => {
                        for (int i = tableViewCalc.rows.Count - 1; i >= 0; i--)
                        {
                            if (tableViewCalc.rows[i].selected)
                            {
                                DirCollect.RemoveCollectItem(DirCollect.DirCollectItems[i]);
                            }
                        }
                        window.UpdateInfo();
                    });

                    menu.ShowAsContext();
                    if (e.type != EventType.Layout)
                    {
                        e.Use();
                    }
                }
            }
            public override void OnGUI()
            {
                this.Space(5)
                .DrawHorizontal(() =>
                {
                    this.Label("Check UIMap Script Name", Styles.toolbar);
                    this.TextField(ref UIMapName);
                });
                this.DrawHorizontal(() =>
                {
                    this.Label("UIMap Gen Directory", Styles.toolbar);
                    this.Label(UIMapDir);
                })
                .Space(30);

                this.ETextField("Panel Name", ref panelName);

                this.DrawHorizontal(() =>
                {
                    this.Label("Drag Panel Gen Directory", Styles.toolbar);
                    this.Label(PanelGenDir);
                    Rect rect = GUILayoutUtility.GetLastRect();
                    if (string.IsNullOrEmpty(PanelGenDir))
                    {
                        rect.DrawOutLine(10, Color.red);
                    }
                    else
                    {
                        rect.DrawOutLine(2, Color.black);
                    }
                    if (rect.Contains(Event.current.mousePosition))
                    {
                        var drag = DragAndDropUtil.Drag(Event.current, rect);
                        if (drag.compelete && drag.enterArera && drag.paths.Length == 1)
                        {
                            string path = drag.paths[0];
                            if (path.Contains("Assets"))
                            {
                                if (path.IsDirectory())
                                {
                                    PanelGenDir = path;
                                }
                                else
                                {
                                    PanelGenDir = path.GetDirPath();
                                }
                                if (!PanelGenDir.Contains(UIMapDir))
                                {
                                    PanelGenDir = string.Empty;
                                }
                            }
                        }
                    }
                })
                .Space(10)
                .DrawHorizontal(() =>
                {
                    this
                    .Button(() =>
                    {
                        if (File.Exists(uimapPath))
                        {
                            EditorWindow.focusedWindow.ShowNotification(new GUIContent("UI Map Have Exist "));
                            return;
                        }
                        CreateUIMap(uimapPath);
                        AssetDatabase.Refresh();
                    }, "Create UIMap")
                    .Space(20)
                    .Button(() =>
                    {
                        if (!File.Exists(uimapPath))
                        {
                            EditorWindow.focusedWindow.ShowNotification(new GUIContent("Create UI Map"));
                            return;
                        }
                        if (string.IsNullOrEmpty(panelName))
                        {
                            EditorWindow.focusedWindow.ShowNotification(new GUIContent("Choose UI Panel Type "));
                            return;
                        }
                        if (string.IsNullOrEmpty(PanelGenDir))
                        {
                            EditorWindow.focusedWindow.ShowNotification(new GUIContent("Set UI Panel Gen Dir "));
                            return;
                        }

                        //                            string paneltype = panelType.Split('.').Last();


                        CreateView(PanelGenDir.CombinePath(ViewName).Append(".lua"));
                        CreateVM(PanelGenDir.CombinePath(VMName).Append(".lua"));
                        WriteMap(uimapPath, panelName);
                        AssetDatabase.Refresh();
                    }, "Gen");
                });
            }