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()); }
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)); }
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; }
/** 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)); } }
public void UpdateNode (Node node) { this.node = node; }
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; }
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; }
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); }
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; }
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(); } } }
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(); }
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); } }
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(); } }