コード例 #1
0
        public static ConnectionGUI LoadConnection(Model.ConnectionData data, Model.ConnectionPointData output, Model.ConnectionPointData input)
        {
            var newCon = ScriptableObject.CreateInstance <ConnectionGUI> ();

            newCon.Init(data, output, input);
            return(newCon);
        }
コード例 #2
0
        public ConnectionData Connect(string label, ConnectionPointData outputPort, ConnectionPointData inputPort)
        {
            if (!outputPort.IsOutput || !inputPort.IsInput)
            {
                return(null);
            }

            var outputNode = m_allNodes.FirstOrDefault(n => n.Id == outputPort.NodeId);
            var inputNode  = m_allNodes.FirstOrDefault(n => n.Id == inputPort.NodeId);

            if (outputNode == null || inputNode == null)
            {
                return(null);
            }

            var existingConnections = m_allConnections
                                      .Where(con => con.FromNodeConnectionPointId == outputPort.Id)
                                      .Where(con => con.FromNodeConnectionPointId != inputPort.Id).ToList();

            foreach (var c in existingConnections)
            {
                m_allConnections.Remove(c);
            }

            var newConnection = new ConnectionData(label, outputPort, inputPort);

            m_allConnections.Add(newConnection);

            return(newConnection);
        }
コード例 #3
0
        public ConnectionPointData AddInputPoint(string label)
        {
            var p = new ConnectionPointData(label, this, true);

            m_inputPoints.Add(p);
            return(p);
        }
コード例 #4
0
        private void UpdateVariant(Model.NodeData n, Variant variant)
        {
            Model.ConnectionPointData p = n.InputPoints.Find(v => v.Id == variant.ConnectionPointId);
            UnityEngine.Assertions.Assert.IsNotNull(p);

            p.Label = variant.Name;
        }
コード例 #5
0
        public ConnectionPointData AddOutputPoint(string label)
        {
            var p = new ConnectionPointData(label, this, false);

            m_outputPoints.Add(p);
            return(p);
        }
コード例 #6
0
ファイル: Filter.cs プロジェクト: tuita520/AssetGraph
        public void UpdateFilterEntry(Model.NodeData n, FilterEntry f)
        {
            Model.ConnectionPointData p = n.OutputPoints.Find(v => v.Id == f.ConnectionPointId);
            UnityEngine.Assertions.Assert.IsNotNull(p);

            p.Label = f.Instance.Object.Label;
        }
コード例 #7
0
 public NodeEvent(EventType type, NodeGUI node, Vector2 localMousePos, Model.ConnectionPointData point)
 {
     this.eventType           = type;
     this.eventSourceNode     = node;
     this.point               = point;
     this.position            = localMousePos;
     this.globalMousePosition = new Vector2(localMousePos.x + node.GetX(), localMousePos.y + node.GetY());
 }
コード例 #8
0
 public ConnectionPointData(ConnectionPointData p)
 {
     this.id         = p.id;
     this.label      = p.label;
     this.parentId   = p.parentId;
     this.isInput    = p.isInput;
     this.buttonRect = p.buttonRect;
 }
コード例 #9
0
 public ConnectionData(string label, ConnectionPointData output, ConnectionPointData input)
 {
     m_id         = Guid.NewGuid().ToString();
     m_label      = label;
     m_fromNodeId = output.NodeId;
     m_fromNodeConnectionPointId = output.Id;
     m_toNodeId = input.NodeId;
     m_toNodeConnectionPoiontId = input.Id;
 }
コード例 #10
0
        public static ConnectionGUI CreateConnection(string label, Model.ConnectionPointData output, Model.ConnectionPointData input)
        {
            var newCon = ScriptableObject.CreateInstance <ConnectionGUI> ();

            newCon.Init(
                new Model.ConnectionData(label, output, input),
                output,
                input
                );
            return(newCon);
        }
コード例 #11
0
 public override bool IsValidInputConnectionPoint(Model.ConnectionPointData point)
 {
     if (!m_useGroupAsVariants)
     {
         if (m_variants.Count > 0 && m_variants.Find(v => v.ConnectionPointId == point.Id) == null)
         {
             return(false);
         }
     }
     return(true);
 }
コード例 #12
0
 public static bool ContainsConnection(this List <ConnectionGUI> connections, Model.ConnectionPointData output, Model.ConnectionPointData input)
 {
     foreach (var con in connections)
     {
         if (con.IsEqual(output, input))
         {
             return(true);
         }
     }
     return(false);
 }
コード例 #13
0
ファイル: ConnectionGUI.cs プロジェクト: reforcehub/samunit
        private void Init(Model.ConnectionData data, Model.ConnectionPointData output, Model.ConnectionPointData input)
        {
            UnityEngine.Assertions.Assert.IsTrue(output.IsOutput, "Given Output point is not output.");
            UnityEngine.Assertions.Assert.IsTrue(input.IsInput, "Given Input point is not input.");

            m_data                  = data;
            m_outputPoint           = output;
            m_inputPoint            = input;
            this.name               = m_data.Label;
            m_groupViewContext      = new GroupViewContext();
            m_connectionButtonStyle = "sv_label_0";
        }
コード例 #14
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)));
            }
        }
コード例 #15
0
        public Dictionary <string, List <AssetReference> > FindAssetGroup(Model.ConnectionPointData point)
        {
            var connection = (point.IsInput) ?
                             m_targetGraph.Connections.Find(c => c.ToNodeConnectionPointId == point.Id):
                             m_targetGraph.Connections.Find(c => c.FromNodeConnectionPointId == point.Id);

            if (connection == null)
            {
                return(new Dictionary <string, List <AssetReference> >());
            }

            if (!m_connectionStreamMap.ContainsKey(connection.Id))
            {
                m_connectionStreamMap[connection.Id] = new Dictionary <string, List <AssetReference> >();
            }

            return(m_connectionStreamMap[connection.Id]);
        }
コード例 #16
0
        public IEnumerable <Dictionary <string, List <AssetReference> > > EnumurateIncomingAssetGroups(Model.ConnectionPointData inputPoint)
        {
            UnityEngine.Assertions.Assert.IsNotNull(inputPoint);
            UnityEngine.Assertions.Assert.IsTrue(inputPoint.IsInput);

            var connections = m_targetGraph.Connections;

            return(m_connectionStreamMap.Where(v => {
                var conn = connections.Find(c => c.Id == v.Key);
                return conn != null && conn.ToNodeConnectionPointId == inputPoint.Id;
            }).Select(v => v.Value));
        }
コード例 #17
0
ファイル: Node.cs プロジェクト: yzx4036/BDFramework.Core
 /// <summary>
 /// Determines whether this instance is valid input connection point the specified point.
 /// </summary>
 /// <returns><c>true</c> if this instance is valid input connection point the specified point; otherwise, <c>false</c>.</returns>
 /// <param name="point">Point.</param>
 public virtual bool IsValidInputConnectionPoint(Model.ConnectionPointData point)
 {
     return(true);
 }
コード例 #18
0
 public bool IsEqual(Model.ConnectionPointData from, Model.ConnectionPointData to)
 {
     return(m_outputPoint == from && m_inputPoint == to);
 }
コード例 #19
0
        public static AssetReference FindFirstIncomingAssetReference(AssetReferenceStreamManager mgr, Model.ConnectionPointData inputPoint)
        {
            var assetGroupEnum = mgr.EnumurateIncomingAssetGroups(inputPoint);

            if (assetGroupEnum == null)
            {
                return(null);
            }

            if (assetGroupEnum.Any())
            {
                var ag = assetGroupEnum.First();
                if (ag.Values.Any())
                {
                    var assets = ag.Values.First();
                    if (assets.Count > 0)
                    {
                        return(assets[0]);
                    }
                }
            }

            return(null);
        }
コード例 #20
0
ファイル: NodeGUI.cs プロジェクト: tuita520/AssetGraph
 private bool IsValidInputConnectionPoint(Model.ConnectionPointData point)
 {
     return(m_data.Operation.Object.IsValidInputConnectionPoint(point));
 }
コード例 #21
0
ファイル: Filter.cs プロジェクト: tuita520/AssetGraph
 public Model.ConnectionPointData GetConnectionPoint(Model.NodeData n, FilterEntry f)
 {
     Model.ConnectionPointData p = n.OutputPoints.Find(v => v.Id == f.ConnectionPointId);
     UnityEngine.Assertions.Assert.IsNotNull(p);
     return(p);
 }
コード例 #22
0
ファイル: Filter.cs プロジェクト: tuita520/AssetGraph
 public FilterEntry(IFilter filter, Model.ConnectionPointData point)
 {
     m_instance = new FilterInstance(filter);
     m_pointId  = point.Id;
 }
コード例 #23
0
ファイル: NodeGUI.cs プロジェクト: tuita520/AssetGraph
        /**
         *      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();
            }
        }
コード例 #24
0
 private Model.ConnectionPointData GetConnectionPoint(Model.NodeData n, Variant v)
 {
     Model.ConnectionPointData p = n.InputPoints.Find(point => point.Id == v.ConnectionPointId);
     UnityEngine.Assertions.Assert.IsNotNull(p);
     return(p);
 }
コード例 #25
0
 public Model.ConnectionPointData GetConnectionPoint(Model.NodeData n, GeneratorEntry e)
 {
     Model.ConnectionPointData p = n.OutputPoints.Find(v => v.Id == e.m_id);
     UnityEngine.Assertions.Assert.IsNotNull(p);
     return(p);
 }
コード例 #26
0
 public Variant(string name, Model.ConnectionPointData point)
 {
     m_name    = name;
     m_pointId = point.Id;
 }
コード例 #27
0
 public GeneratorEntry(string name, SerializableMultiTargetInstance i, Model.ConnectionPointData point)
 {
     m_name     = name;
     m_id       = point.Id;
     m_instance = new SerializableMultiTargetInstance(i);
 }
コード例 #28
0
 public override bool IsValidInputConnectionPoint(Model.ConnectionPointData point)
 {
     return(true);
 }