Beispiel #1
0
 protected override void CloseScope()
 {
     if (node != null)
     {
         node.ResetErrorStatus();
     }
     NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_SAVE));
 }
Beispiel #2
0
        public void RemoveGeneratorEntry(NodeGUI node, GeneratorEntry e)
        {
            m_entries.Remove(e);
            var point = GetConnectionPoint(node.Data, e);

            node.Data.OutputPoints.Remove(point);
            // event must raise to remove connection associated with point
            NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, point));
        }
Beispiel #3
0
        public void ReorderFilterEntryList(ReorderableList list)
        {
            m_node.Data.OutputPoints.Sort((Model.ConnectionPointData x, Model.ConnectionPointData y) => {
                int xIndex = m_filter.FindIndex(f => f.ConnectionPointId == x.Id);
                int yIndex = m_filter.FindIndex(f => f.ConnectionPointId == y.Id);

                return(xIndex - yIndex);
            });
            m_OnValueChanged();
            // redo node output due to filter condition change
            NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, m_node));
        }
Beispiel #4
0
        public void UpdateGeneratorEntry(NodeGUI node, Model.NodeData data, GeneratorEntry e)
        {
            Model.ConnectionPointData p = node.Data.OutputPoints.Find(v => v.Id == e.m_id);
            UnityEngine.Assertions.Assert.IsNotNull(p);
            p.Label = e.m_name;

            if (node != null)
            {
                // event must raise to propagate change to connection associated with point
                NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_LABELCHANGED, node, Vector2.zero, GetConnectionPoint(node.Data, e)));
            }
        }
Beispiel #5
0
        protected override void CloseScope()
        {
            if (node != null)
            {
                //node.UpdateNodeRect();
                node.ResetErrorStatus();
                NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, node));
            }
            if (saveOnScopeEnd)
            {
//				NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_SAVE));
            }
        }
Beispiel #6
0
        private void RemoveFromFilterEntryList(ReorderableList list)
        {
            // how is removing taking effect?
            // -> list.index

            var removingItem = m_filter [list.index];

            using (new RecordUndoScope("Remove Filter Condition", m_node, true)){
                // event must raise to remove connection associated with point
                NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, m_node, Vector2.zero, GetConnectionPoint(m_node.Data, removingItem)));
                RemoveFilterCondition(m_node.Data, removingItem);
                m_OnValueChanged();
            }
        }
Beispiel #7
0
        public void DrawConnectionOutputPointMark(NodeEvent eventSource, bool justConnecting, Event current)
        {
            var defaultPointTex = _assetGraphGuiConfig.ConnectionPoint;
            var lastColor       = GUI.color;

            bool shouldDrawEnable =
                !(eventSource != null && eventSource.eventSourceNode != null &&
                  !Model.ConnectionData.CanConnect(m_data, eventSource.eventSourceNode.Data)
                  );

            bool shouldDrawWithEnabledColor =
                shouldDrawEnable && justConnecting &&
                eventSource != null &&
                eventSource.eventSourceNode.Id != this.Id &&
                eventSource.point.IsInput;

            var globalMousePosition = current.mousePosition;

            foreach (var point in m_data.OutputPoints)
            {
                var pointRegion = point.GetGlobalPointRegion(this);

                if (shouldDrawWithEnabledColor)
                {
                    GUI.color = _assetGraphGuiConfig.COLOR_CAN_CONNECT;
                }
                else
                {
                    GUI.color = (justConnecting) ? _assetGraphGuiConfig.COLOR_CAN_NOT_CONNECT : _assetGraphGuiConfig.COLOR_CONNECTED;
                }

                GUI.DrawTexture(
                    pointRegion,
                    defaultPointTex
                    );
                GUI.color = lastColor;

                // eventPosition is contained by outputPointRect.
                if (pointRegion.Contains(globalMousePosition))
                {
                    if (current.type == EventType.MouseDown)
                    {
                        NodeGUIUtility.NodeEventHandler(
                            new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_BEGIN, this, current.mousePosition, point));
                    }
                }
            }
        }
Beispiel #8
0
        public EditorGUI.DisabledScope DrawOverrideTargetToggle(NodeGUI node, bool status, Action <bool> onStatusChange)
        {
            if (currentEditingGroup == BuildTargetUtility.DefaultTarget)
            {
                return(new EditorGUI.DisabledScope(false));
            }

            bool newStatus = GUILayout.Toggle(status,
                                              "Override for " + NodeGUIUtility.GetPlatformButtonFor(currentEditingGroup).ui.tooltip);

            if (newStatus != status && onStatusChange != null)
            {
                onStatusChange(newStatus);
            }
            return(new EditorGUI.DisabledScope(!newStatus));
        }
Beispiel #9
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;
        }
Beispiel #10
0
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            EditorGUILayout.HelpBox("Overwrite Import Setting: Overwrite import settings of incoming assets.", MessageType.Info);
            editor.UpdateNodeName(node);

            // prevent inspector flicking by new Editor changing active selction
            node.SetActive(true);

            using (new EditorGUILayout.VerticalScope()) {
                Type importerType = null;
                Type assetType    = null;

                var referenceImporter = GetReferenceAssetImporter(node.Data, false);
                if (referenceImporter != null)
                {
                    importerType = referenceImporter.GetType();
                    assetType    = TypeUtility.GetMainAssetTypeAtPath(AssetDatabase.GUIDToAssetPath(m_referenceAssetGuid));
                }
                else
                {
                    GUILayout.Space(10f);
                    using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                        EditorGUILayout.HelpBox("Import setting type can be set by incoming asset, or you can specify by selecting.", MessageType.Info);
                        using (new EditorGUILayout.HorizontalScope()) {
                            EditorGUILayout.LabelField("Importer Type");
                            if (GUILayout.Button("", "Popup", GUILayout.MinWidth(150f)))
                            {
                                var menu = new GenericMenu();

                                var guiMap   = ImporterConfiguratorUtility.GetImporterConfiguratorGuiNameTypeMap();
                                var guiNames = guiMap.Keys.ToArray();

                                for (var i = 0; i < guiNames.Length; i++)
                                {
                                    var index = i;
                                    menu.AddItem(
                                        new GUIContent(guiNames [i]),
                                        false,
                                        () => {
                                        ResetConfig(node.Data);
                                        m_configureImporterFor = guiMap [guiNames [index]];
                                        // call Validate
                                        NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_UPDATED, node));
                                    }
                                        );
                                }
                                menu.ShowAsContext();
                            }
                        }
                    }
                    return;
                }

                if (importerType != null && assetType != null)
                {
                    GUILayout.Space(10f);
                    DoCustomAssetGUI(assetType, importerType, node, editor, onValueChanged);
                }

                // get reference importer again (enabling custom asset this time)
                referenceImporter = GetReferenceAssetImporter(node.Data, true);

                if (referenceImporter != null)
                {
                    var configurator = m_configuratorInstance.Get <IAssetImporterConfigurator> (editor.CurrentEditingGroup);
                    if (configurator != null)
                    {
                        GUILayout.Space(10f);

                        Action onChangedAction = () => {
                            using (new RecordUndoScope(string.Format("Change {0} Setting", node.Name), node)) {
                                m_configuratorInstance.Set(editor.CurrentEditingGroup, configurator);
                                onValueChanged();
                            }
                        };

                        configurator.OnInspectorGUI(referenceImporter, editor.CurrentEditingGroup, onChangedAction);
                    }

                    if (m_importerEditor == null)
                    {
                        m_importerEditor = Editor.CreateEditor(referenceImporter);
                    }
                }

                if (m_importerEditor != null)
                {
                    GUILayout.Space(10f);
                    GUILayout.Label(string.Format("Import Setting ({0})", importerType.Name));
                    m_importerEditor.OnInspectorGUI();
                }

                GUILayout.Space(40f);
                using (new EditorGUILayout.HorizontalScope(GUI.skin.box)) {
                    GUILayout.Space(4f);
                    EditorGUILayout.LabelField("Clear Saved Import Setting");

                    if (GUILayout.Button("Clear"))
                    {
                        if (EditorUtility.DisplayDialog("Clear Saved Import Setting",
                                                        string.Format("Do you want to reset saved import setting for \"{0}\"? This operation is not undoable.", node.Name), "OK", "Cancel"))
                        {
                            ResetConfig(node.Data);
                        }
                    }
                }
            }
        }
Beispiel #11
0
 public RecordUndoScope(string message, NodeGUI node, bool saveOnScopeEnd)
 {
     this.node           = node;
     this.saveOnScopeEnd = saveOnScopeEnd;
     NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_RECORDUNDO, message));
 }
Beispiel #12
0
 public RecordUndoScope(string message, NodeGUI node)
 {
     this.node = node;
     NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_RECORDUNDO, message));
 }
        public override void OnInspectorGUI(NodeGUI node, AssetReferenceStreamManager streamManager, NodeGUIEditor editor, Action onValueChanged)
        {
            if (m_bundleNameTemplate == null)
            {
                return;
            }

            EditorGUILayout.HelpBox("Configure Bundle From Group: Create asset bundle settings from incoming group of assets.", MessageType.Info);
            editor.UpdateNodeName(node);

            GUILayout.Space(10f);

            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var newUseGroupAsVariantValue = GUILayout.Toggle(m_useGroupAsVariants, "Use input group as variants");
                if (newUseGroupAsVariantValue != m_useGroupAsVariants)
                {
                    using (new RecordUndoScope("Change Bundle Config", node, true)){
                        m_useGroupAsVariants = newUseGroupAsVariantValue;

                        List <Variant> rv = new List <Variant>(m_variants);
                        foreach (var v in rv)
                        {
                            NodeGUIUtility.NodeEventHandler(
                                new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, GetConnectionPoint(node.Data, v)));
                            RemoveVariant(node.Data, v);
                        }
                        onValueChanged();
                    }
                }

                using (new EditorGUI.DisabledScope(newUseGroupAsVariantValue)) {
                    GUILayout.Label("Variants:");
                    var     variantNames = m_variants.Select(v => v.Name).ToList();
                    Variant removing     = null;
                    foreach (var v in m_variants)
                    {
                        using (new GUILayout.HorizontalScope()) {
                            if (GUILayout.Button("-", GUILayout.Width(30)))
                            {
                                removing = v;
                            }
                            else
                            {
                                GUIStyle s             = new GUIStyle((GUIStyle)"TextFieldDropDownText");
                                Action   makeStyleBold = () => {
                                    s.fontStyle = FontStyle.Bold;
                                    s.fontSize  = 12;
                                };

                                ValidateVariantName(v.Name, variantNames,
                                                    makeStyleBold,
                                                    makeStyleBold,
                                                    makeStyleBold);

                                var variantName = EditorGUILayout.TextField(v.Name, s);

                                if (variantName != v.Name)
                                {
                                    using (new RecordUndoScope("Change Variant Name", node, true)){
                                        v.Name = variantName;
                                        UpdateVariant(node.Data, v);
                                        onValueChanged();
                                    }
                                }
                            }
                        }
                    }
                    if (GUILayout.Button("+"))
                    {
                        using (new RecordUndoScope("Add Variant", node, true)){
                            if (m_variants.Count == 0)
                            {
                                NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_DELETE_ALL_CONNECTIONS_TO_POINT, node, Vector2.zero, node.Data.InputPoints[0]));
                            }
                            AddVariant(node.Data, Model.Settings.BUNDLECONFIG_VARIANTNAME_DEFAULT);
                            onValueChanged();
                        }
                    }
                    if (removing != null)
                    {
                        using (new RecordUndoScope("Remove Variant", node, true)){
                            // event must raise to remove connection associated with point
                            NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTIONPOINT_DELETED, node, Vector2.zero, GetConnectionPoint(node.Data, removing)));
                            RemoveVariant(node.Data, removing);
                            onValueChanged();
                        }
                    }
                }
            }

            //Show target configuration tab
            editor.DrawPlatformSelector(node);
            using (new EditorGUILayout.VerticalScope(GUI.skin.box)) {
                var disabledScope = editor.DrawOverrideTargetToggle(node, m_bundleNameTemplate.ContainsValueOf(editor.CurrentEditingGroup), (bool enabled) => {
                    using (new RecordUndoScope("Remove Target Bundle Name Template Setting", node, true)){
                        if (enabled)
                        {
                            m_bundleNameTemplate[editor.CurrentEditingGroup] = m_bundleNameTemplate.DefaultValue;
                        }
                        else
                        {
                            m_bundleNameTemplate.Remove(editor.CurrentEditingGroup);
                        }
                        onValueChanged();
                    }
                });

                using (disabledScope) {
                    var bundleNameTemplate = EditorGUILayout.TextField("Bundle Name Template", m_bundleNameTemplate[editor.CurrentEditingGroup]).ToLower();

                    if (bundleNameTemplate != m_bundleNameTemplate[editor.CurrentEditingGroup])
                    {
                        using (new RecordUndoScope("Change Bundle Name Template", node, true)){
                            m_bundleNameTemplate[editor.CurrentEditingGroup] = bundleNameTemplate;
                            onValueChanged();
                        }
                    }
                }
            }
        }
Beispiel #14
0
        /**
         *      retrieve mouse events for this node in this GraphEditor window.
         */
        private void HandleNodeMouseEvent()
        {
            switch (Event.current.type)
            {
            /*
             *              handling release of mouse drag from this node to another node.
             *              this node doesn't know about where the other node is. the master only knows.
             *              only emit event.
             */
            case EventType.Ignore: {
                NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_END, this, Event.current.mousePosition, null));
                break;
            }

            /*
             *      check if the mouse-down point is over one of the connectionPoint in this node.
             *      then emit event.
             */
            case EventType.MouseDown: {
                Model.ConnectionPointData result = IsOverConnectionPoint(Event.current.mousePosition);

                if (result != null)
                {
                    NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_CONNECTING_BEGIN, this, Event.current.mousePosition, result));
                    break;
                }
                else
                {
                    NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_CLICKED,
                                                                  this, Event.current.mousePosition, null));
                }
                break;
            }
            }

            /*
             *      retrieve mouse events for this node in|out of this GraphTool window.
             */
            switch (Event.current.rawType)
            {
            case EventType.MouseUp: {
                bool eventSent = false;
                // send EVENT_CONNECTION_ESTABLISHED event if MouseUp performed on ConnectionPoint
                Action <Model.ConnectionPointData> raiseEventIfHit = (Model.ConnectionPointData point) => {
                    // Only one connectionPoint can send NodeEvent.
                    if (eventSent)
                    {
                        return;
                    }

                    // If InputConnectionPoint is not valid at this moment, ignore
                    if (!IsValidInputConnectionPoint(point))
                    {
                        return;
                    }

                    if (point.Region.Contains(Event.current.mousePosition))
                    {
                        NodeGUIUtility.NodeEventHandler(
                            new NodeEvent(NodeEvent.EventType.EVENT_CONNECTION_ESTABLISHED,
                                          this, Event.current.mousePosition, point));
                        eventSent = true;
                        return;
                    }
                };
                m_data.InputPoints.ForEach(raiseEventIfHit);
                m_data.OutputPoints.ForEach(raiseEventIfHit);
                break;
            }
            }

            /*
             *      right click to open Context menu
             */
            if (Event.current.type == EventType.ContextClick || (Event.current.type == EventType.MouseUp && Event.current.button == 1))
            {
                var menu = new GenericMenu();

                Data.Operation.Object.OnContextMenuGUI(menu);

                menu.AddItem(
                    new GUIContent("Delete"),
                    false,
                    () => {
                    NodeGUIUtility.NodeEventHandler(new NodeEvent(NodeEvent.EventType.EVENT_NODE_DELETE, this, Vector2.zero, null));
                }
                    );
                menu.ShowAsContext();
                Event.current.Use();
            }
        }