Пример #1
0
 public OnNodeEvent(EventType type, Node node, Vector2 localMousePos, ConnectionPoint conPoint)
 {
     this.eventType = type;
     this.eventSourceNode = node;
     this.eventSourceConnectionPoint = conPoint;
     this.globalMousePosition = new Vector2(localMousePos.x + node.GetX(), localMousePos.y + node.GetY());
 }
Пример #2
0
		public static Connection NewConnection (string label, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input) {
			return new Connection(
				label,
				Guid.NewGuid().ToString(),
				startNodeId,
				output,
				endNodeId,
				input
			);
		}
Пример #3
0
		public static Connection LoadConnection (string label, string connectionId, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input) {
			return new Connection(
				label,
				connectionId,
				startNodeId,
				output,
				endNodeId,
				input
			);
		}
Пример #4
0
		private Connection (string label, string connectionId, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input) {
			conInsp = ScriptableObject.CreateInstance<ConnectionInspector>();
			conInsp.hideFlags = HideFlags.DontSave;

			this.label = label;
			this.connectionId = connectionId;

			this.startNodeId = startNodeId;
			this.outputPoint = output;
			this.endNodeId = endNodeId;
			this.inputPoint = input;

			connectionButtonStyle = "sv_label_0";
		}
Пример #5
0
		public static bool ContainsConnection(this List<Connection> connections, Node start, ConnectionPoint output, Node end, ConnectionPoint input) {
			foreach (var con in connections) {
				if (con.IsSameDetail(start, output, end, input)) return true;
			}
			return false;
		}
Пример #6
0
		private Rect OutputRect (ConnectionPoint outputPoint) {
			return new Rect(
				baseRect.x + baseRect.width - 8f, 
				baseRect.y + outputPoint.buttonRect.y + 1f, 
				AssetGraphGUISettings.CONNECTION_POINT_MARK_SIZE, 
				AssetGraphGUISettings.CONNECTION_POINT_MARK_SIZE
			);
		}
Пример #7
0
        public Vector2 GlobalConnectionPointPosition(ConnectionPoint p)
        {
            var x = baseRect.x + p.buttonRect.x;
            if (p.isInput) x = baseRect.x + p.buttonRect.x;
            if (p.isOutput) x = baseRect.x + p.buttonRect.x + NodeEditorSettings.POINT_SIZE;

            var y = baseRect.y + p.buttonRect.y + NodeEditorSettings.POINT_SIZE/2;

            return new Vector2(x, y);
        }
Пример #8
0
 private void DeleteConnectionByRelation(Node startNode, ConnectionPoint startPoint, Node endNode, ConnectionPoint endPoint)
 {
     connections.Where(con => con.IsSameDetail(startNode, startPoint, endNode, endPoint)).
         Select(con => connections.Remove(con));
 }
Пример #9
0
        private Connection(string label, string connectionId, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input)
        {
            conInsp           = ScriptableObject.CreateInstance <ConnectionInspector>();
            conInsp.hideFlags = HideFlags.DontSave;

            this.label        = label;
            this.connectionId = connectionId;

            this.startNodeId = startNodeId;
            this.outputPoint = output;
            this.endNodeId   = endNodeId;
            this.inputPoint  = input;

            connectionButtonStyle = "sv_label_0";
        }
Пример #10
0
 public static Connection NewConnection(string label, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input)
 {
     return(new Connection(
                label,
                Guid.NewGuid().ToString(),
                startNodeId,
                output,
                endNodeId,
                input
                ));
 }
Пример #11
0
 public static bool ContainsConnection(this List <Connection> connections, Node start, ConnectionPoint output, Node end, ConnectionPoint input)
 {
     foreach (var con in connections)
     {
         if (con.IsSameDetail(start, output, end, input))
         {
             return(true);
         }
     }
     return(false);
 }
Пример #12
0
 public static Connection LoadConnection(string label, string connectionId, string startNodeId, ConnectionPoint output, string endNodeId, ConnectionPoint input)
 {
     return(new Connection(
                label,
                connectionId,
                startNodeId,
                output,
                endNodeId,
                input
                ));
 }
Пример #13
0
 public bool IsEndAtConnectionPoint(ConnectionPoint p)
 {
     return(inputPoint == p);
 }
Пример #14
0
 public bool IsStartAtConnectionPoint(ConnectionPoint p)
 {
     return(outputPoint == p);
 }
Пример #15
0
		public Vector2 GlobalConnectionPointPosition(ConnectionPoint p) {
			var x = 0f;
			var y = 0f;

			if (p.isInput) {
				x = baseRect.x;
				y = baseRect.y + p.buttonRect.y + (p.buttonRect.height / 2f) - 1f;
			}

			if (p.isOutput) {
				x = baseRect.x + baseRect.width;
				y = baseRect.y + p.buttonRect.y + (p.buttonRect.height / 2f) - 1f;
			}

			return new Vector2(x, y);
		}
Пример #16
0
 private bool IsConnectablePointFromTo(ConnectionPoint sourcePoint, ConnectionPoint destPoint)
 {
     if (sourcePoint.isOutput != destPoint.isOutput && sourcePoint.isInput != destPoint.isInput) {
         return true;
     }
     return false;
 }
Пример #17
0
        /**
            create new connection if same relationship is not exist yet.
        */
        private void AddConnection(string label, Node startNode, ConnectionPoint startPoint, Node endNode, ConnectionPoint endPoint)
        {
            Undo.RecordObject(this, "Add Connection");

            var connectionsFromThisNode = connections
                .Where(con => con.startNodeId == startNode.nodeId)
                .Where(con => con.outputPoint == startPoint)
                .ToList();
            if (connectionsFromThisNode.Any()) {
                var alreadyExistConnection = connectionsFromThisNode[0];
                DeleteConnectionById(alreadyExistConnection.connectionId);
            }

            if (!connections.ContainsConnection(startNode, startPoint, endNode, endPoint)) {
                connections.Add(Connection.NewConnection(label, startNode.nodeId, startPoint, endNode.nodeId, endPoint));
            }
        }
Пример #18
0
		public bool IsStartAtConnectionPoint (ConnectionPoint p) {
			return outputPoint == p;
		}
Пример #19
0
        public void AddConnectionPoint(ConnectionPoint adding)
        {
            connectionPoints.Add(adding);

            // update node size by number of connectionPoint.
            if (3 < connectionPoints.Count) {
                this.baseRect = new Rect(baseRect.x, baseRect.y, baseRect.width, NodeEditorSettings.NODE_BASE_HEIGHT + (20 * (connectionPoints.Count - 3)));
            }

            // update all connection point's index.

            UpdateNodeRect();
        }
Пример #20
0
		public bool IsEndAtConnectionPoint (ConnectionPoint p) {
			return inputPoint == p;
		}
Пример #21
0
		public bool IsSameDetail (Node start, ConnectionPoint output, Node end, ConnectionPoint input) {
			if (
				startNodeId == start.nodeId &&
				outputPoint == output && 
				endNodeId == end.nodeId &&
				inputPoint == input
			) {
				return true;
			}
			return false;
		}
Пример #22
0
		public void AddConnectionPoint (ConnectionPoint adding) {
			connectionPoints.Add(adding);
			UpdateNodeRect();
		}