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());
 }
 public void UpdateNode(Node node)
 {
     this.node = node;
 }
Exemple #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;
 }
Exemple #4
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;
 }
        public void DuplicateNode(Node node)
        {
            var newNode = node.DuplicatedNode(
                nodes.Count,
                node.GetX() + 10f,
                node.GetY() + 10f
            );

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

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

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

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

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

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

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

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

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

            nodes.Add(newNode);
        }
        /**
            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));
            }
        }
        private static Dictionary<string, object> JsonRepresentationDict(Node node)
        {
            var nodeDict = new Dictionary<string, object>();

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

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

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

            nodeDict[AssetBundleGraphSettings.NODE_POS] = posDict;

            switch (node.kind) {
                case AssetBundleGraphSettings.NodeKind.LOADER_GUI: {
                    nodeDict[AssetBundleGraphSettings.NODE_LOADER_LOAD_PATH] = node.loadPath.ReadonlyDict();
                    break;
                }
                case AssetBundleGraphSettings.NodeKind.EXPORTER_GUI: {
                    nodeDict[AssetBundleGraphSettings.NODE_EXPORTER_EXPORT_PATH] = node.exportPath.ReadonlyDict();
                    break;
                }

                case AssetBundleGraphSettings.NodeKind.FILTER_SCRIPT:
                case AssetBundleGraphSettings.NodeKind.PREFABRICATOR_SCRIPT: {
                    nodeDict[AssetBundleGraphSettings.NODE_SCRIPT_TYPE] = node.scriptType;
                    nodeDict[AssetBundleGraphSettings.NODE_SCRIPT_PATH] = node.scriptPath;
                    break;
                }

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

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

                case AssetBundleGraphSettings.NodeKind.MODIFIER_GUI: {
                    nodeDict[AssetBundleGraphSettings.NODE_MODIFIER_PACKAGES] = node.modifierPackages.ReadonlyDict();
                    break;
                }

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

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

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

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

                default: {
                    Debug.LogError("failed to match:" + node.kind);
                    break;
                }
            }
            return nodeDict;
        }
Exemple #8
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.filterContainsKeytypes,
         (this.importerPackages != null) ? this.importerPackages.ReadonlyDict() : null,
         (this.modifierPackages != null) ? this.modifierPackages.ReadonlyDict() : null,
         (this.groupingKeyword != null) ? this.groupingKeyword.ReadonlyDict() : null,
         (this.bundleNameTemplate != null) ? this.bundleNameTemplate.ReadonlyDict() : null,
         (this.bundleUseOutput != null) ? this.bundleUseOutput.ReadonlyDict() : null,
         (this.enabledBundleOptions != null) ? this.enabledBundleOptions.ReadonlyDict() : null
     );
     return duplicatedNode;
 }
Exemple #9
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();
                }
            }
Exemple #10
0
            private void UpdateDeleteSetting(Node currentNode)
            {
                var currentNodePlatformPackageKey = GraphStackController.Platform_Package_Key(currentNode.currentPlatform);

                if (currentNodePlatformPackageKey == AssetBundleGraphSettings.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();
                    }
                }
            }