Ejemplo n.º 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());
 }
Ejemplo n.º 2
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));
 }
Ejemplo n.º 3
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;
		}
Ejemplo n.º 4
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));
            }
        }
Ejemplo n.º 5
0
		public void UpdateNode (Node node) {
			this.node = node;
		}
Ejemplo n.º 6
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;
		}
Ejemplo n.º 7
0
		private static Dictionary<string, object> JsonRepresentationDict (Node node) {
			var nodeDict = new Dictionary<string, object>();

			nodeDict[AssetGraphSettings.NODE_NAME] = node.name;
			nodeDict[AssetGraphSettings.NODE_ID] = node.nodeId;
			nodeDict[AssetGraphSettings.NODE_KIND] = node.kind.ToString();

			var outputLabels = node.OutputPointLabels();
			nodeDict[AssetGraphSettings.NODE_OUTPUT_LABELS] = outputLabels;

			var posDict = new Dictionary<string, object>();
			posDict[AssetGraphSettings.NODE_POS_X] = node.GetX();
			posDict[AssetGraphSettings.NODE_POS_Y] = node.GetY();

			nodeDict[AssetGraphSettings.NODE_POS] = posDict;

			switch (node.kind) {
				case AssetGraphSettings.NodeKind.LOADER_GUI: {
					nodeDict[AssetGraphSettings.NODE_LOADER_LOAD_PATH] = node.loadPath.ReadonlyDict();
					break;
				}
				case AssetGraphSettings.NodeKind.EXPORTER_GUI: {
					nodeDict[AssetGraphSettings.NODE_EXPORTER_EXPORT_PATH] = node.exportPath.ReadonlyDict();
					break;
				}
				
				case AssetGraphSettings.NodeKind.FILTER_SCRIPT:
				case AssetGraphSettings.NodeKind.IMPORTER_SCRIPT:
				case AssetGraphSettings.NodeKind.PREFABRICATOR_SCRIPT:
				case AssetGraphSettings.NodeKind.BUNDLIZER_SCRIPT: {
					nodeDict[AssetGraphSettings.NODE_SCRIPT_TYPE] = node.scriptType;
					nodeDict[AssetGraphSettings.NODE_SCRIPT_PATH] = node.scriptPath;
					break;
				}

				case AssetGraphSettings.NodeKind.FILTER_GUI: {
					nodeDict[AssetGraphSettings.NODE_FILTER_CONTAINS_KEYWORDS] = node.filterContainsKeywords;
					break;
				}

				case AssetGraphSettings.NodeKind.IMPORTER_GUI:{
					nodeDict[AssetGraphSettings.NODE_IMPORTER_PACKAGES] = node.importerPackages.ReadonlyDict();
					break;
				}

				case AssetGraphSettings.NodeKind.GROUPING_GUI: {
					nodeDict[AssetGraphSettings.NODE_GROUPING_KEYWORD] = node.groupingKeyword.ReadonlyDict();
					break;
				}

				case AssetGraphSettings.NodeKind.PREFABRICATOR_GUI: {
					nodeDict[AssetGraphSettings.NODE_SCRIPT_TYPE] = node.scriptType;
					nodeDict[AssetGraphSettings.NODE_SCRIPT_PATH] = node.scriptPath;
					break;
				}

				case AssetGraphSettings.NodeKind.BUNDLIZER_GUI: {
					nodeDict[AssetGraphSettings.NODE_BUNDLIZER_BUNDLENAME_TEMPLATE] = node.bundleNameTemplate.ReadonlyDict();
					break;
				}

				case AssetGraphSettings.NodeKind.BUNDLEBUILDER_GUI: {
					nodeDict[AssetGraphSettings.NODE_BUNDLEBUILDER_ENABLEDBUNDLEOPTIONS] = node.enabledBundleOptions.ReadonlyDict();
					break;
				}

				default: {
					Debug.LogError("failed to match:" + node.kind);
					break;
				}
			}
			return nodeDict;
		}
Ejemplo n.º 8
0
		public void DuplicateNode (Node node) {
			var newNode = node.DuplicatedNode(
				nodes.Count,
				node.GetX() + 10f,
				node.GetY() + 10f
			);

			switch (newNode.kind) {
				case AssetGraphSettings.NodeKind.LOADER_GUI: {
					newNode.AddConnectionPoint(new OutputPoint(AssetGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
					break;
				}

				case AssetGraphSettings.NodeKind.FILTER_GUI: {
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					foreach (var outputPointLabel in newNode.filterContainsKeywords) {
						newNode.AddConnectionPoint(new OutputPoint(outputPointLabel));
					}
					break;
				}
				
				case AssetGraphSettings.NodeKind.IMPORTER_GUI: {
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					newNode.AddConnectionPoint(new OutputPoint(AssetGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
					break;
				}

				case AssetGraphSettings.NodeKind.GROUPING_GUI: {
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					newNode.AddConnectionPoint(new OutputPoint(AssetGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
					break;
				}
				
				case AssetGraphSettings.NodeKind.PREFABRICATOR_GUI:{
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					newNode.AddConnectionPoint(new OutputPoint(AssetGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
					break;
				}

				case AssetGraphSettings.NodeKind.BUNDLIZER_GUI: {
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					newNode.AddConnectionPoint(new OutputPoint(AssetGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
					break;
				}

				case AssetGraphSettings.NodeKind.BUNDLEBUILDER_GUI: {
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					newNode.AddConnectionPoint(new OutputPoint(AssetGraphSettings.DEFAULT_OUTPUTPOINT_LABEL));
					break;
				}

				case AssetGraphSettings.NodeKind.EXPORTER_GUI: {
					newNode.AddConnectionPoint(new InputPoint(AssetGraphSettings.DEFAULT_INPUTPOINT_LABEL));
					break;
				}
				default: {
					Debug.LogError("no kind match:" + newNode.kind);
					break;
				}
			}

			nodes.Add(newNode);
		}
Ejemplo n.º 9
0
		public Node DuplicatedNode (int newIndex, float newX, float newY) {
			var duplicatedNode = new Node(
				newIndex,
				this.name,
				Guid.NewGuid().ToString(),
				this.kind, 
				newX,
				newY,
				this.scriptType,
				this.scriptPath,
				(this.loadPath != null) ? loadPath.ReadonlyDict() : null,
				(this.exportPath != null) ? this.exportPath.ReadonlyDict() : null,
				this.filterContainsKeywords,
				(this.importerPackages != null) ? this.importerPackages.ReadonlyDict() : null,
				(this.groupingKeyword != null) ? this.groupingKeyword.ReadonlyDict() : null,
				(this.bundleNameTemplate != null) ? this.bundleNameTemplate.ReadonlyDict() : null,
				(this.enabledBundleOptions != null) ? this.enabledBundleOptions.ReadonlyDict() : null
			);
			return duplicatedNode;
		}
Ejemplo n.º 10
0
			private void UpdateDeleteSetting (Node currentNode) {
				var currentNodePlatformPackageKey = GraphStackController.Platform_Package_Key(currentNode.currentPlatform, currentNode.currentPackage);

				if (currentNodePlatformPackageKey == AssetGraphSettings.PLATFORM_DEFAULT_NAME) return;

				using (new EditorGUILayout.HorizontalScope()) {
					GUILayout.FlexibleSpace();
					if (GUILayout.Button("Use Default Setting", GUILayout.Width(150))) {
						currentNode.BeforeSave();
						currentNode.DeleteCurrentPackagePlatformKey(currentNodePlatformPackageKey);
						GUI.FocusControl(string.Empty);
						currentNode.Save();
					}
				}
			}
Ejemplo n.º 11
0
			private void ConfigureSharedPackages (Node packagesParentNode) {
				for (int i = 0; i < NodeSharedPackages.Count; i++) {
					GUILayout.BeginHorizontal();
					{
						if (GUILayout.Button("-")) {
							NodeSharedPackages.RemoveAt(i);
							packagesParentNode.UpdatePackages();
							break;
						} else {
							var newPackage = EditorGUILayout.TextField("Package", NodeSharedPackages[i]);
							if (newPackage != NodeSharedPackages[i]) {
								NodeSharedPackages[i] = newPackage;
								packagesParentNode.UpdatePackages();
								break;
							}
						}
					}
					GUILayout.EndHorizontal();
				}

				GUILayout.BeginHorizontal();
				{
					// add contains keyword interface.
					if (GUILayout.Button("Add New Package")) {
						NodeSharedPackages.Add(AssetGraphSettings.PLATFORM_NEW_PACKAGE + "_" + NodeSharedPackages.Count);
						packagesParentNode.UpdatePackages();
					}
					if (GUILayout.Button("Done", GUILayout.Width(50))) {
						packageEditMode = false;
					}
				}
				GUILayout.EndHorizontal();
			}
Ejemplo n.º 12
0
			private void UpdateCurrentPackage (Node packagesParentNode) {
				using (new EditorGUILayout.HorizontalScope()) {
					GUILayout.Label("Package:");
					var currentPackageStr = packagesParentNode.currentPackage;

					// if package is empty => package is default one. use (None).
					if (string.IsNullOrEmpty(currentPackageStr)) currentPackageStr = AssetGraphSettings.PLATFORM_NONE_PACKAGE;

					if (GUILayout.Button(currentPackageStr, "Popup")) {
						Action DefaultSelected = () => {
							packagesParentNode.PackageChanged(string.Empty);
						};

						Action<string> ExistSelected = (string package) => {
							packagesParentNode.PackageChanged(package);
						};

						ShowPackageMenu(packagesParentNode.currentPackage, DefaultSelected, ExistSelected);
						GUI.FocusControl(string.Empty);
					}

					if (GUILayout.Button("+", GUILayout.Width(30))) {
						packageEditMode = true;
						GUI.FocusControl(string.Empty);
						return;
					}
				}

				if (packageEditMode) {
					GUILayout.Space(10f);
					EditorGUI.EndDisabledGroup();
					
					// package added or deleted.
					ConfigureSharedPackages(packagesParentNode);

					EditorGUI.BeginDisabledGroup(true);
					GUILayout.Space(10f);
				}
			}
Ejemplo n.º 13
0
			private void UpdateNodeName (Node node) {
				var newName = EditorGUILayout.TextField("Node Name", node.name);
				
				var overlapping = Node.allNodeNames.GroupBy(x => x)
					.Where(group => group.Count() > 1)
					.Select(group => group.Key);
				if (overlapping.Any() && overlapping.Contains(newName)) {
					EditorGUILayout.HelpBox("node name is overlapping:" + newName, MessageType.Error);
				}

				if (newName != node.name) {
					node.BeforeSave();
					node.name = newName;
					node.UpdateNodeRect();
					node.Save();
				}
			}