Пример #1
0
 public static lhTriggerManager GetInstance()
 {
     if (m_instance != null)
     {
         return(null);
     }
     return(m_instance = new lhTriggerManager());
 }
Пример #2
0
 void OnDestroy()
 {
     if (m_triggerManager != null)
     {
         if (EditorUtility.DisplayDialog("Information", "Are you sure save?", "Ok", "Cancel"))
         {
             m_triggerManager.Apply();
         }
         m_triggerManager.Dispose();
         m_triggerManager = null;
     }
     if (m_GUIStyles != null)
     {
         m_GUIStyles.Dispose();
         m_GUIStyles = null;
     }
 }
Пример #3
0
 public void Dispose()
 {
     m_instance = null;
 }
Пример #4
0
        void OnGUI()
        {
            if (m_triggerManager == null)
            {
                m_GUIStyles      = lhGUIStyles.GetInstance();
                m_triggerManager = lhTriggerManager.GetInstance();
                m_dragHandler    = new lhDragHandler();
                m_selectList     = new List <lhTriggerManager.Node>();
            }
            if (Event.current.keyCode == KeyCode.LeftControl)
            {
                if (Event.current.type == EventType.KeyDown)
                {
                    m_isControl = true;
                }
                else if (Event.current.type == EventType.keyUp)
                {
                    m_isControl = false;
                }
            }
            Rect curRectWindow = EditorGUILayout.BeginVertical(lhGUIStyles.GetStyle("OL Box"));

            {
                EditorGUILayout.BeginHorizontal(EditorStyles.toolbar, GUILayout.ExpandWidth(true));
                {
                    if (GUILayout.Button("Create", EditorStyles.toolbarButton))
                    {
                        m_triggerManager.CreateGroup();
                    }
                    GUILayout.FlexibleSpace();
                    if (GUILayout.Button("Revert", EditorStyles.toolbarButton))
                    {
                        if (EditorUtility.DisplayDialog("Information", "Are you sure Revert", "Ok", "Cancel"))
                        {
                            m_triggerManager.Revert();
                        }
                    }
                    if (GUILayout.Button("Apply", EditorStyles.toolbarButton))
                    {
                        if (EditorUtility.DisplayDialog("Information", "Are you sure Save", "Ok", "Cancel"))
                        {
                            m_triggerManager.Apply();
                        }
                    }
                    if (GUILayout.Button("Export", EditorStyles.toolbarButton))
                    {
                        if (EditorUtility.DisplayDialog("Information", "Are you sure Save", "Ok", "Cancel"))
                        {
                            m_triggerManager.Export();
                        }
                    }
                    if (GUILayout.Button("Settings", EditorStyles.toolbarButton))
                    {
                        lhTriggerSettingEditor.Show();
                    }
                } EditorGUILayout.EndHorizontal();

                GUI.SetNextControlName("ScrollPosition");
                m_scrollPosition = EditorGUILayout.BeginScrollView(m_scrollPosition);
                {
                    foreach (var group in m_triggerManager.triggerList)
                    {
                        Rect itemRect = EditorGUILayout.BeginHorizontal(EditorStyles.toolbarButton, GUILayout.ExpandWidth(true));
                        {
                            GUILayout.Label(group.index.ToString());
                            GUIContent content    = group.open ? new GUIContent("-") : new GUIContent("+");
                            Rect       dropButton = GUILayoutUtility.GetRect(content, EditorStyles.miniLabel, GUILayout.ExpandWidth(false));
                            if (GUI.Button(dropButton, content, EditorStyles.miniLabel))
                            {
                                group.open = !group.open;
                            }
                            if (group.renaming)
                            {
                                GUIContent cancelContent = new GUIContent("×");
                                if (GUI.Button(GUILayoutUtility.GetRect(cancelContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)), cancelContent))
                                {
                                    group.renaming = false;
                                    GUI.FocusControl("ScrollPosition");
                                }
                                GUIContent certainContent = new GUIContent("√");
                                if (GUI.Button(GUILayoutUtility.GetRect(certainContent, EditorStyles.miniButton, GUILayout.ExpandWidth(false)), certainContent))
                                {
                                    if (m_triggerManager.HasSameGroupName(group, group.oldGroupName))
                                    {
                                        EditorUtility.DisplayDialog("Error", "Has the same groupName,please rename the groupname", "Ok");
                                    }
                                    else
                                    {
                                        group.EndRename();
                                        GUI.FocusControl("ScrollPosition");
                                    }
                                }
                                group.oldGroupName = EditorGUILayout.TextField(group.oldGroupName);
                            }
                            else
                            {
                                GUILayout.Label(group.triggerName);
                            }

                            GUILayout.FlexibleSpace();

                            GUIContent deleteContent = new GUIContent("x");
                            if (GUI.Button(GUILayoutUtility.GetRect(deleteContent, EditorStyles.toolbarButton, GUILayout.ExpandWidth(false)), deleteContent, EditorStyles.toolbarButton))
                            {
                                if (EditorUtility.DisplayDialog("Information", "Are you sure delete group?", "Ok", "Cancel"))
                                {
                                    m_triggerManager.DeleteGroup(group);
                                    Repaint();
                                    return;
                                }
                            }
                        } GUILayout.EndHorizontal();

                        if (group.open)
                        {
                            EditorGUILayout.BeginVertical();
                            {
                                for (int i = 0; i < group.treeList.Count; i++)
                                {
                                    TreeLayout(group.treeList[i]);
                                }
                            } EditorGUILayout.EndVertical();
                        }

                        if (IsMouseOn(itemRect))
                        {
                            if (Event.current.keyCode == KeyCode.F2)
                            {
                                group.StartRename();
                                Repaint();
                            }
                            if (Event.current.keyCode == KeyCode.Return)
                            {
                                if (m_triggerManager.HasSameGroupName(group, group.oldGroupName))
                                {
                                    EditorUtility.DisplayDialog("Error", "Has the same groupName,please rename the groupname", "Ok");
                                }
                                else
                                {
                                    group.EndRename();
                                    Repaint();
                                    GUI.FocusControl("ScrollPosition");
                                }
                            }
                            if (Event.current.type == EventType.DragUpdated)
                            {
                                m_dragHandler.SetVisualMode(DragAndDropVisualMode.Move);
                            }
                            if (Event.current.type == EventType.DragPerform)
                            {
                                //var movedNode = (lhTriggerManager.TriggerGroup.Node)m_dragHandler.GetGenericData("DependenceNode");
                                //if (!group.treeList.Contains(movedNode))
                                //{
                                //    movedNode.DeleteOwn();
                                //    group.AddTree(movedNode);
                                //    m_dragHandler.AcceptDrag();
                                //}
                            }
                        }
                    }
                } EditorGUILayout.EndScrollView();
            } EditorGUILayout.EndVertical();
        }