Пример #1
0
        /// <summary>
        /// 任务点GUI事件处理
        /// </summary>
        private void OnPointEventHandle()
        {
            if (_currentContent != null && Event.current != null)
            {
                Vector2 mousePosition = Event.current.mousePosition;

                switch (Event.current.type)
                {
                case EventType.MouseDown:
                    if (Event.current.button == 1)
                    {
                        GenericMenu gm = new GenericMenu();
                        gm.AddItem(new GUIContent("<New Task Point Script>"), false, () =>
                        {
                            NewTaskPointScript();
                        });
                        List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                        {
                            return(type.IsSubclassOf(typeof(TaskPointBase)));
                        });
                        for (int i = 0; i < types.Count; i++)
                        {
                            Type               type        = types[i];
                            string             contentName = type.FullName;
                            TaskPointAttribute attri       = type.GetCustomAttribute <TaskPointAttribute>();
                            if (attri != null)
                            {
                                contentName = attri.Name;
                            }
                            gm.AddItem(new GUIContent("Add Task Point/" + contentName), false, () =>
                            {
                                AddPoint(type, mousePosition);
                            });
                        }
                        StringToolkit.BeginNoRepeatNaming();
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            TaskPointBase point = _currentContent.Points[i];
                            gm.AddItem(new GUIContent(StringToolkit.GetNoRepeatName("Find Task Point/" + point.Name)), false, () =>
                            {
                                FindPoint(point);
                            });
                        }
                        gm.ShowAsContext();
                    }
                    break;

                case EventType.MouseDrag:
                    if (Event.current.button == 2)
                    {
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            _currentContent.Points[i].OnDrag(Event.current.delta);
                        }
                        GUI.changed = true;
                    }
                    break;
                }

                for (int i = 0; i < _currentContent.Points.Count; i++)
                {
                    _currentContent.Points[i].OnPointEventHandle(Event.current, _currentContent);
                }
            }
        }
Пример #2
0
        /// <summary>
        /// 任务点GUI事件处理
        /// </summary>
        private void OnPointEventHandle()
        {
            if (_currentContent != null && Event.current != null)
            {
                Vector2 pos = Event.current.mousePosition;

                switch (Event.current.type)
                {
                case EventType.MouseDown:
                    if (Event.current.button == 1)
                    {
                        GenericMenu gm = new GenericMenu();
                        gm.AddItem(new GUIContent(GetWord("Add Task Point") + "/默认"), false, () =>
                        {
                            AddPoint(_currentContent, typeof(TaskPointDefault), pos);
                        });
                        List <Type> types = ReflectionToolkit.GetTypesInRunTimeAssemblies(type =>
                        {
                            return(type.IsSubclassOf(typeof(TaskPointBase)) && !type.IsAbstract && type != typeof(TaskPointDefault));
                        });
                        for (int i = 0; i < types.Count; i++)
                        {
                            Type               type      = types[i];
                            string             pointName = type.FullName;
                            TaskPointAttribute attribute = type.GetCustomAttribute <TaskPointAttribute>();
                            if (attribute != null)
                            {
                                pointName = attribute.Name;
                            }
                            gm.AddItem(new GUIContent(GetWord("Add Task Point") + "/" + pointName), false, () =>
                            {
                                AddPoint(_currentContent, type, pos);
                            });
                        }
                        StringToolkit.BeginNoRepeatNaming();
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            TaskPointBase point = _currentContent.Points[i];
                            gm.AddItem(new GUIContent(StringToolkit.GetNoRepeatName(GetWord("Find Task Point") + "/" + point.Name)), false, () =>
                            {
                                FindPoint(point);
                            });
                        }
                        gm.AddSeparator("");
                        CopyTaskPoint(gm);
                        PasteTaskPoint(gm, pos);
                        gm.AddSeparator("");
                        gm.AddItem(new GUIContent(GetWord("Collapse All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsExpand      = false;
                            }
                            GUI.changed = true;
                        });
                        gm.AddItem(new GUIContent(GetWord("Expand All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsExpand      = true;
                            }
                            GUI.changed = true;
                        });
                        gm.AddSeparator("");
                        gm.AddItem(new GUIContent(GetWord("Enable All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsEnable      = true;
                            }
                            GUI.changed = true;
                        });
                        gm.AddItem(new GUIContent(GetWord("Disable All")), false, () =>
                        {
                            for (int i = 0; i < _currentContent.Points.Count; i++)
                            {
                                TaskPointBase point = _currentContent.Points[i];
                                point.IsEnable      = false;
                            }
                            GUI.changed = true;
                        });
                        gm.AddSeparator("");
                        gm.AddItem(new GUIContent(GetWord("<New Task Point Script>")), false, () =>
                        {
                            NewTaskPointScript();
                        });
                        gm.ShowAsContext();
                    }
                    break;

                case EventType.MouseDrag:
                    if (Event.current.button == 2)
                    {
                        for (int i = 0; i < _currentContent.Points.Count; i++)
                        {
                            _currentContent.Points[i].OnDrag(Event.current.delta);
                        }
                        GUI.changed = true;
                    }
                    break;

                case EventType.KeyDown:
                    switch (Event.current.keyCode)
                    {
                    case KeyCode.LeftAlt:
                    case KeyCode.RightAlt:
                        _isBreakDepend = true;
                        GUI.changed    = true;
                        break;
                    }
                    break;

                case EventType.KeyUp:
                    switch (Event.current.keyCode)
                    {
                    case KeyCode.LeftAlt:
                    case KeyCode.RightAlt:
                        _isBreakDepend = false;
                        GUI.changed    = true;
                        break;
                    }
                    break;
                }

                for (int i = 0; i < _currentContent.Points.Count; i++)
                {
                    _currentContent.Points[i].OnPointEventHandle(Event.current, _contentAsset, _currentContent, _getWord);
                }
            }
        }