Beispiel #1
0
        void AddToFilterEntryList(ReorderableList list)
        {
            var map = FilterUtility.GetAttributeAssemblyQualifiedNameMap();

            if (map.Keys.Count > 1)
            {
                GenericMenu menu = new GenericMenu();
                foreach (var name in map.Keys)
                {
                    var guiName = name;
                    menu.AddItem(new GUIContent(guiName), false, () => {
                        using (new RecordUndoScope("Add Filter Condition", m_node)){
                            var filter = FilterUtility.CreateFilter(guiName);
                            AddFilterCondition(m_node.Data, filter);
                            m_OnValueChanged();
                        }
                        list.index = m_filter.Count - 1;
                    });
                }
                menu.ShowAsContext();
            }
            else
            {
                using (new RecordUndoScope("Add Filter Condition", m_node)){
                    AddFilterCondition(m_node.Data, new FilterByNameAndType());
                    m_OnValueChanged();
                    list.index = m_filter.Count - 1;
                }
            }
        }
Beispiel #2
0
        private void DrawFilterEntryListElement(Rect rect, int index, bool selected, bool focused)
        {
            bool oldEnabled = GUI.enabled;

            GUI.enabled = CanEditFilterEntry(index);

            var     cond   = m_filter[index];
            IFilter filter = cond.Instance.Object;

            if (filter == null)
            {
                using (new GUILayout.VerticalScope()) {
                    EditorGUILayout.HelpBox(
                        $"Failed to deserialize assigned filter({cond.Instance.ClassName}). Select a valid class.", MessageType.Error);
                    if (GUILayout.Button(cond.Instance.ClassName, "Popup", GUILayout.MinWidth(150f)))
                    {
                        var map = FilterUtility.GetAttributeAssemblyQualifiedNameMap();
                        NodeGUI.ShowTypeNamesMenu(cond.Instance.ClassName, map.Keys.ToList(), (string selectedGUIName) =>
                        {
                            using (new RecordUndoScope("Change Filter Setting", m_node)) {
                                var newFilter = FilterUtility.CreateFilter(selectedGUIName);
                                cond.Instance = new FilterInstance(newFilter);
                                m_OnValueChanged();
                            }
                        }
                                                  );
                    }
                }
            }
            else
            {
                cond.Instance.Object.OnInspectorGUI(rect, () => {
                    using (new RecordUndoScope("Change Filter Setting", m_node)) {
                        cond.Instance.Save();
                        UpdateFilterEntry(m_node.Data, cond);
                        // event must raise to propagate change to connection associated with point
                        NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, m_node, Vector2.zero, GetConnectionPoint(m_node.Data, cond)));
                        m_OnValueChanged();
                    }
                });
            }


            GUI.enabled = oldEnabled;
        }